Skip to content

Commit fc2f774

Browse files
authored
Merge pull request #107 from qikify/v3-master
Update docs
2 parents 288f3e3 + c0ee725 commit fc2f774

File tree

4 files changed

+50
-89
lines changed

4 files changed

+50
-89
lines changed

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
);
2929

3030
return mergeConfig(previousConfig, {
31-
...config,
31+
resolve: { ...config.resolve },
3232
plugins: [
3333
svgLoader(),
3434
eslintPlugin({

README.md

Lines changed: 38 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Polaris Vue
1+
# Polaris Vue (Support Vue 3.0)
22

33
Polaris Vue by qikify only supports **Vue 3.0.0+**.
44

@@ -36,103 +36,64 @@ yarn add @qikify/polaris-vue
3636
Use as a Vue 3 plugin (globally registers all components):
3737

3838
```js
39-
import Vue from 'vue';
40-
import PolarisVue from '@qikify/polaris-vue';
41-
import '@qikify/polaris-vue/dist/polaris-vue.css';
42-
43-
Vue.use(PolarisVue);
44-
45-
new Vue({
46-
components: {
47-
// all Polaris Vue components already registered
48-
}
49-
});
39+
//main.js
40+
import { createApp } from 'vue'
41+
import PolarisVue from '@qikify/polaris-vue' // (✓)
42+
import '@qikify/polaris-vue/dist/style.css' // (✓) This will be deprecated in the future, right after Vue 3 supports css injections.
43+
import App from './App.vue'
44+
45+
//...
46+
const app = createApp(App)
47+
app.use(PolarisVue) // (✓)
48+
...
5049
```
5150

5251
**OR** use individual component:
5352

5453
```js
55-
import Vue from 'vue';
5654
import { List, Icon } from '@qikify/polaris-vue';
57-
58-
new Vue({
59-
components: {
60-
List,
61-
Icon
62-
}
63-
});
6455
```
6556

6657
<br/>
6758

68-
## **Styles**
69-
70-
Polaris Vue supports both **CSS** & **SCSS**, you can find the neccessary styles files in `node_modules/@qikify/polaris-vue/dist/`.
71-
72-
#### **SCSS**
73-
74-
To use scss, you can import the `main.scss` file in your `.vue` or `.scss` file.
75-
76-
Or you can import separated scss files from dist to your project scss file.
77-
78-
Example:
59+
### **AppProvider**
60+
The AppProvider component is `required` to use PolarisVue. Without it, the components in your application will not function correctly. You must wrap the root (the top) of your application in the app provider component.
7961

8062
```javascript
81-
<style lang="scss">
82-
@import '@qikify/polaris-vue/dist/scss/main.scss';
83-
</style>
63+
// App.vue
64+
<template>
65+
<AppProvider>
66+
...
67+
</AppProvider>
68+
</template>
69+
70+
<script></script>
8471
```
8572

8673
<br/>
8774

88-
## Aliasing Vue import
75+
## De-duplicating Vue version
8976

90-
`PolarisVue` and `PortalVue` require access to the global Vue reference (via `import Vue from 'vue'`).
91-
92-
If you are using a specific build of Vue (i.e. runtime-only vs. compiler + runtime), you will need to set up an alias to `vue` in your bundler config to ensure that your project, **PolarisVue** and **PortalVue** are all using the same build version of Vue. If you are seeing an error such as `$attr and $listeners is readonly`, or `Multiple instances of Vue detected`, then you will need to set up an alias.
93-
94-
<br/>
77+
`PolarisVue`, other packages and your project may require access to the global Vue reference. So sometimes, you may get the runtime error message like:
9578

96-
Example: Vue alias for `Vue CLI` in `vue.config.js`
97-
98-
```js
99-
module.exports = {
100-
// ...
101-
resolve: {
102-
alias: {
103-
// If using the runtime only build
104-
vue$: 'vue/dist/vue.runtime.esm.js' // 'vue/dist/vue.runtime.common.js' for webpack 1
105-
// Or if using full build of Vue (runtime + compiler)
106-
// vue$: 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1
107-
}
108-
}
109-
}
79+
```bash
80+
TypeError: Cannot read properties of null (reading 'isCE')
81+
renderSlot(...)
82+
...
11083
```
11184

112-
Example: Vue alias in `webpack.config.js`
85+
To avoid this, simply add `dedupe: ['vue']` to your `vite.config.ts` file, like below:
11386

114-
```js
115-
const path = require('path')
116-
117-
module.exports = {
118-
chainWebpack: config => {
119-
config.resolve.alias.set(
120-
'vue$',
121-
// If using the runtime only build
122-
path.resolve(__dirname, 'node_modules/vue/dist/vue.runtime.esm.js')
123-
// Or if using full build of Vue (runtime + compiler)
124-
// path.resolve(__dirname, 'node_modules/vue/dist/vue.esm.js')
125-
)
126-
}
127-
}
87+
```bash
88+
export default defineConfig({
89+
resolve: {
90+
...
91+
dedupe: ['vue'],
92+
},
93+
...
94+
});
12895
```
12996

130-
<br/>
131-
132-
## Components List
133-
134-
See [Component Status](https://qikify.github.io/polaris-vue/?path=/docs/component-status--page) in documentation.
135-
13697
---
13798

13899
## Developers / Build
@@ -146,8 +107,8 @@ yarn
146107

147108
# Create a Demo.vue file to test
148109

149-
# Development & Demo - http://localhost:1902
150-
yarn serve
110+
# Development & Demo
111+
yarn dev
151112
```
152113

153114
## Contributing

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"typecheck": "vue-tsc --noEmit",
3131
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
3232
"storybook": "start-storybook -p 6006",
33-
"build-storybook": "build-storybook"
33+
"build-storybook": "rimraf ./docs && build-storybook -o docs"
3434
},
3535
"dependencies": {
3636
"@shopify/polaris-icons": "^4.17.0",

src/components/InlineError/README.stories.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dedent from 'ts-dedent';
12
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
23

34
import { InlineError } from '@/polaris-vue';
@@ -9,7 +10,7 @@ import { InlineError } from '@/polaris-vue';
910
message: {
1011
control: { type: 'text' },
1112
table: {
12-
type: { summary: 'String | Vue Component' },
13+
type: { summary: 'string | component' },
1314
},
1415
},
1516
default: {
@@ -20,10 +21,10 @@ import { InlineError } from '@/polaris-vue';
2021
}}
2122
/>
2223

23-
export const Template = (args, { argTypes }) => ({
24-
props: Object.keys(argTypes),
24+
export const Template = (args) => ({
2525
components: { InlineError },
26-
template: `<InlineError v-bind="$props"/>`,
26+
setup() { return { args }; },
27+
template: `<InlineError v-bind="args"/>`,
2728
});
2829

2930
# Inline error
@@ -38,13 +39,12 @@ Use inline errors to help merchants understand why a form input may not be valid
3839
message: 'Store name is required',
3940
fieldID: 'myFieldID'
4041
}}
41-
parameters={{
42+
parameters = {{
4243
docs: {
43-
transformSource: (source) => {
44-
const tmpSource = source
45-
.replace(/<template>/, '')
46-
.replace(/<\/template>/, '');
47-
return tmpSource;
44+
source: {
45+
code: dedent`
46+
<InlineError fieldID="myFieldID" message="Store name is required"/>
47+
`,
4848
},
4949
},
5050
}}

0 commit comments

Comments
 (0)