Skip to content

Commit b3050c5

Browse files
committed
Update: DescriptionList component
1 parent 3d52cdb commit b3050c5

File tree

9 files changed

+136
-4
lines changed

9 files changed

+136
-4
lines changed

src/classes/DescriptionList.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"DescriptionList":"Polaris-DescriptionList","Term":"Polaris-DescriptionList__Term","spacingTight":"Polaris-DescriptionList--spacingTight","Description":"Polaris-DescriptionList__Description"}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template lang="pug">
2+
dl(:class="className")
3+
slot
4+
</template>
5+
6+
<script setup lang="ts">
7+
import { computed } from 'vue';
8+
import { classNames } from 'polaris-react/src/utilities/css';
9+
import styles from '@/classes/DescriptionList.json';
10+
11+
const props = withDefaults(defineProps<{
12+
/**
13+
* Determines the spacing between list items
14+
* @default 'loose'
15+
*/
16+
spacing?: 'loose' | 'tight';
17+
}>(),
18+
{
19+
spacing: 'loose',
20+
});
21+
22+
const className = computed(() => {
23+
return classNames(
24+
styles.DescriptionList,
25+
props.spacing === 'tight' && styles.spacingTight,
26+
);
27+
});
28+
</script>
29+
<style lang="scss">
30+
@import 'polaris-react/src/components/DescriptionList/DescriptionList.scss';
31+
</style>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template lang="pug">
2+
dd(:class="className")
3+
slot
4+
</template>
5+
6+
<script setup lang="ts">
7+
import { classNames } from 'polaris-react/src/utilities/css';
8+
import styles from '@/classes/DescriptionList.json';
9+
10+
const className = classNames(styles.Description);
11+
</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template lang="pug">
2+
dt(:class="className")
3+
slot
4+
</template>
5+
6+
<script setup lang="ts">
7+
import { classNames } from 'polaris-react/src/utilities/css';
8+
import styles from '@/classes/DescriptionList.json';
9+
10+
const className = classNames(styles.Term);
11+
</script>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
2+
import { DescriptionList, Dt, Dd } from '@/polaris-vue';
3+
import dedent from 'ts-dedent';
4+
5+
<Meta
6+
title="Components / Lists and tables / Description List"
7+
component={ DescriptionList }
8+
argTypes={{
9+
default: {
10+
table: {
11+
disable: true,
12+
},
13+
},
14+
}}
15+
/>
16+
17+
export const Template = (args) => ({
18+
components: { DescriptionList, Dt, Dd },
19+
setup() { return { args }; },
20+
template: `<DescriptionList v-bind="args">
21+
<Dt>Logistics</Dt>
22+
<Dd>
23+
The management of products or other resources as they travel between a point of origin and a destination.
24+
</Dd>
25+
<Dt>Sole proprietorship</Dt>
26+
<Dd>
27+
A business structure where a single individual both owns and runs the company.
28+
</Dd>
29+
<Dt>Discount code</Dt>
30+
<Dd>
31+
A series of numbers and/or letters that an online shopper may enter at checkout to get a discount or special offer.
32+
</Dd>
33+
</DescriptionList>`,
34+
});
35+
36+
# Description List
37+
38+
Description lists are a way to organize and explain related information.
39+
They're particularly useful when you need to list and define terms such as in a glossary.
40+
41+
<font color="#FF7900"><strong>Warning:</strong></font> Use component name as case-sensitive (<code>&lt;Dt&gt;</code> &amp; <code>&lt;Dd&gt;</code>) to prevent conflict with <code>&lt;dt&gt;</code> <code>&lt;dd&gt;</code> HTML element.
42+
43+
<Canvas>
44+
<Story
45+
name="Description List"
46+
height="60px"
47+
parameters={{
48+
docs: {
49+
source: {
50+
code: dedent`
51+
<DescriptionList>
52+
<Dt>Logistics</Dt>
53+
<Dd>
54+
The management of products or other resources as they travel between a point of origin and a destination.
55+
</Dd>
56+
<Dt>Sole proprietorship</Dt>
57+
<Dd>
58+
A business structure where a single individual both owns and runs the company.
59+
</Dd>
60+
<Dt>Discount code</Dt>
61+
<Dd>
62+
A series of numbers and/or letters that an online shopper may enter at checkout to get a discount or special offer.
63+
</Dd>
64+
</DescriptionList>
65+
`,
66+
},
67+
},
68+
}}
69+
>
70+
{Template.bind({})}
71+
</Story>
72+
</Canvas>
73+
74+
<ArgsTable story="Description List" />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default as DescriptionList } from './DescriptionList.vue';
2+
export { default as Dt } from './DescriptionListTerm.vue';
3+
export { default as Dd } from './DescriptionListDesc.vue';

src/components/Heading/README.stories.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ For example, card components generally use headings as their title.
3131
}}
3232
/>
3333

34-
export const Template = (args, { argTypes }) => ({
35-
props: Object.keys(argTypes),
34+
export const Template = (args) => ({
3635
components: { Heading },
36+
setup() { return { args }; },
3737
template: `
38-
<Heading v-bind="$props">
38+
<Heading v-bind="args">
3939
Online store dashboard
4040
</Heading>
4141
`,

src/components/Select/Select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Labelled(
8080
</template>
8181

8282
<script setup lang="ts">
83-
import { computed, useSlots, isProxy } from 'vue';
83+
import { computed, useSlots } from 'vue';
8484
import type { Action, Error } from '@/utilities/type';
8585
import { classNames } from 'polaris-react/src/utilities/css';
8686
import { UseUniqueId } from '@/use';

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export * from './Connected';
1616
export * from './ContextualSaveBar';
1717
export * from './CustomProperties';
1818
export * from './DatePicker';
19+
export * from './DescriptionList';
1920
export * from './DisplayText';
2021
export * from './EventListener';
2122
export * from './ExceptionList';

0 commit comments

Comments
 (0)