Skip to content

Commit b55ccd1

Browse files
committed
Update: svg loader for Icon components & README
1 parent a241567 commit b55ccd1

File tree

7 files changed

+53
-33
lines changed

7 files changed

+53
-33
lines changed

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
},
2020
'@storybook/addon-links',
2121
'@storybook/addon-essentials',
22-
// '@storybook/addon-knobs',
22+
'@storybook/addon-knobs',
2323
],
2424
webpackFinal: async (config, { configType }) => {
2525
config.module.rules.push(

.storybook/manager-head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
width: 14px;
1313
height: 14px;
1414
margin-top: 2px;
15-
color: rgb(16,128,67);
15+
/* color: rgb(16,128,67); */
1616
}
1717

1818
#storybook-explorer-tree .sidebar-item[data-selected="true"] svg {

src/Demo.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
list-item Yellow
55
list-item Red
66
list-item Blue
7+
8+
icon(source="CirclePlusMinor")
79
</template>
810

911
<script lang="ts">
1012
import { Component, Vue } from 'vue-property-decorator';
11-
import { List, ListItem } from './polaris-vue';
13+
import { List, ListItem, Icon } from './polaris-vue';
1214
1315
@Component({
1416
components: {
1517
List,
1618
ListItem,
19+
Icon,
1720
},
1821
})
1922
export default class Demo extends Vue {}

src/components/Icon/Icon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { VisuallyHidden } from '../VisuallyHidden';
3030
export const getPolarisIcon = async (
3131
iconName: string,
3232
): Promise<VueConstructor<Vue>> => {
33-
const icon = await import(`@shopify/polaris-icons/dist/svg/${iconName}.svg`);
33+
const icon = await import(`!vue-svg-loader!@shopify/polaris-icons/dist/svg/${iconName}.svg`);
3434
return icon;
3535
};
3636

src/components/Icon/README.stories.mdx

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1-
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
1+
import { Meta, Story, Canvas, ArgsTable, Source } from '@storybook/addon-docs';
22

33
import { Icon } from '@/polaris-vue';
44

55
<Meta
66
title="Components / Images &amp; Icons / Icon"
77
component={ Icon }
88
argTypes={{
9-
source: {
10-
name: 'source',
11-
options: [
12-
'placeholder',
13-
],
14-
control: { type: 'select' },
15-
table: {
16-
type: {
17-
summary: 'functionComponent | "placeholder" | svg',
18-
},
9+
accessibilityLabel: {
10+
table: {
11+
type: { summary: null },
12+
},
13+
},
14+
backdrop: {
15+
table: {
16+
type: { summary: null },
17+
},
18+
},
19+
source: {
20+
name: 'source',
21+
defaultValue: 'CirclePlusMinor',
22+
options: [
23+
'CirclePlusMinor',
24+
'placeholder',
25+
],
26+
control: {
27+
type: 'select',
28+
labels: {
29+
CirclePlusMinor: 'default',
1930
},
31+
},
32+
table: {
33+
type: {
34+
summary: 'Shopify SVG Icon | "placeholder" | svg',
35+
},
36+
},
2037
},
21-
color: {
38+
color: {
2239
name: 'color',
2340
options: [
41+
null,
2442
'base',
2543
'subdued',
2644
'critical',
@@ -30,10 +48,15 @@ import { Icon } from '@/polaris-vue';
3048
'success',
3149
'primary',
3250
],
33-
control: { type: 'select' },
51+
control: {
52+
type: 'select',
53+
labels: {
54+
null: 'default',
55+
},
56+
},
3457
table: {
3558
type: {
36-
summary: 'base | subdued | critical | interactive | warning | highlight | success | primary'
59+
summary: null
3760
},
3861
},
3962
},
@@ -57,6 +80,10 @@ Icons are used to visually communicate core parts of the product and available a
5780
They can act as wayfinding tools to help merchants more easily understand where they are in the product,
5881
and common interaction patterns that are available.
5982

83+
*Note: To use icons, you must add `vue-svg-loader` package to your project first, by running:* `yarn add -D vue-svg-loader`
84+
85+
You can find icon list from **Shopify Icon Library**: [here](https://polaris-icons.shopify.com/).
86+
6087
<Canvas>
6188
<Story name="Icon">
6289
{Template.bind({})}

src/components/VisuallyHidden/README.stories.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export const Template = (args, { argTypes }) => ({
2727
props: Object.keys(argTypes),
2828
components: { VisuallyHidden },
2929
template: `<div>
30-
<VisuallyHidden>
31-
<span>Hidden content</span>
32-
</VisuallyHidden>
33-
<p>Content passed down have been hide, choose "show code" to see more clearly<p/>
34-
<div/>`,
30+
<VisuallyHidden>
31+
<span>Hidden content</span>
32+
</VisuallyHidden>
33+
<p>Content passed down have been hide, choose "show code" to see more clearly</p>
34+
</div>`,
3535
});
3636

3737
# Visually hidden

vue.config.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,5 @@ module.exports = {
1515
config.resolve.alias
1616
.set('@', path.resolve(__dirname, 'src'))
1717
.set('~', path.resolve(__dirname, 'node_modules/'));
18-
19-
// SVG loader
20-
const svgRule = config.module.rule('svg');
21-
svgRule.uses.clear();
22-
svgRule
23-
.use('babel-loader')
24-
.loader('babel-loader')
25-
.end()
26-
.use('vue-svg-loader')
27-
.loader('vue-svg-loader');
2818
},
2919
};

0 commit comments

Comments
 (0)