tide-design-system 2.0.22 → 2.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/.eslintrc.cjs +90 -0
  2. package/.storybook/main.ts +60 -0
  3. package/.storybook/preview.ts +252 -0
  4. package/dist/css/grid-layout.css +7 -3
  5. package/dist/tide-design-system.js +45 -39
  6. package/index.ts +122 -0
  7. package/package.json +8 -12
  8. package/src/assets/css/animation.css +14 -0
  9. package/src/assets/css/dynamic-buttons.css +79 -0
  10. package/src/assets/css/dynamic-utilities.css +39 -0
  11. package/src/assets/css/grid-layout.css +71 -0
  12. package/src/assets/css/main.css +5 -0
  13. package/src/assets/css/realm/aero.css +42 -0
  14. package/src/assets/css/realm/atv.css +43 -0
  15. package/src/assets/css/realm/boatmart.css +42 -0
  16. package/src/assets/css/realm/cycle.css +42 -0
  17. package/src/assets/css/realm/equip.css +42 -0
  18. package/src/assets/css/realm/pwc.css +42 -0
  19. package/src/assets/css/realm/rv.css +50 -0
  20. package/src/assets/css/realm/snow.css +42 -0
  21. package/src/assets/css/realm/truck.css +42 -0
  22. package/src/assets/css/reset.css +79 -0
  23. package/src/assets/css/storybook.css +9 -0
  24. package/src/assets/css/utilities.css +1602 -0
  25. package/src/assets/css/variables.css +118 -0
  26. package/src/assets/svg/icons/IconAccountBalance.svg +5 -0
  27. package/src/assets/svg/icons/IconAdd.svg +3 -0
  28. package/src/assets/svg/icons/IconAiDescription.svg +7 -0
  29. package/src/assets/svg/icons/IconAlignSpace.svg +3 -0
  30. package/src/assets/svg/icons/IconApplePay.svg +5 -0
  31. package/src/assets/svg/icons/IconArrowBack.svg +3 -0
  32. package/src/assets/svg/icons/IconArrowForward.svg +3 -0
  33. package/src/assets/svg/icons/IconArrowRight.svg +3 -0
  34. package/src/assets/svg/icons/IconAssignment.svg +5 -0
  35. package/src/assets/svg/icons/IconAwardStar.svg +5 -0
  36. package/src/assets/svg/icons/IconBookmark.svg +5 -0
  37. package/src/assets/svg/icons/IconCalendarMonth.svg +5 -0
  38. package/src/assets/svg/icons/IconCall.svg +5 -0
  39. package/src/assets/svg/icons/IconCheck.svg +3 -0
  40. package/src/assets/svg/icons/IconChevronLeft.svg +3 -0
  41. package/src/assets/svg/icons/IconChevronRight.svg +3 -0
  42. package/src/assets/svg/icons/IconClear.svg +5 -0
  43. package/src/assets/svg/icons/IconClose.svg +3 -0
  44. package/src/assets/svg/icons/IconCycle.svg +5 -0
  45. package/src/assets/svg/icons/IconDelete.svg +5 -0
  46. package/src/assets/svg/icons/IconDiamond.svg +5 -0
  47. package/src/assets/svg/icons/IconDraft.svg +3 -0
  48. package/src/assets/svg/icons/IconEdit.svg +5 -0
  49. package/src/assets/svg/icons/IconError.svg +5 -0
  50. package/src/assets/svg/icons/IconExpandContent.svg +3 -0
  51. package/src/assets/svg/icons/IconExpandLess.svg +3 -0
  52. package/src/assets/svg/icons/IconExpandMore.svg +3 -0
  53. package/src/assets/svg/icons/IconFacebook.svg +5 -0
  54. package/src/assets/svg/icons/IconFavorite.svg +5 -0
  55. package/src/assets/svg/icons/IconFavoriteFilled.svg +5 -0
  56. package/src/assets/svg/icons/IconFormatBold.svg +5 -0
  57. package/src/assets/svg/icons/IconFormatItalic.svg +3 -0
  58. package/src/assets/svg/icons/IconFormatListBulleted.svg +5 -0
  59. package/src/assets/svg/icons/IconForum.svg +5 -0
  60. package/src/assets/svg/icons/IconGavel.svg +5 -0
  61. package/src/assets/svg/icons/IconGoogle.svg +18 -0
  62. package/src/assets/svg/icons/IconGooglePay.svg +5 -0
  63. package/src/assets/svg/icons/IconGrid.svg +3 -0
  64. package/src/assets/svg/icons/IconHeight.svg +3 -0
  65. package/src/assets/svg/icons/IconHelp.svg +5 -0
  66. package/src/assets/svg/icons/IconInfo.svg +5 -0
  67. package/src/assets/svg/icons/IconInsertText.svg +5 -0
  68. package/src/assets/svg/icons/IconInstagram.svg +5 -0
  69. package/src/assets/svg/icons/IconIosShare.svg +5 -0
  70. package/src/assets/svg/icons/IconLayout.svg +5 -0
  71. package/src/assets/svg/icons/IconLinkedIn.svg +5 -0
  72. package/src/assets/svg/icons/IconLocalShipping.svg +5 -0
  73. package/src/assets/svg/icons/IconLock.svg +5 -0
  74. package/src/assets/svg/icons/IconMail.svg +5 -0
  75. package/src/assets/svg/icons/IconMenu.svg +3 -0
  76. package/src/assets/svg/icons/IconMoreHoriz.svg +5 -0
  77. package/src/assets/svg/icons/IconNotifications.svg +5 -0
  78. package/src/assets/svg/icons/IconOpenInNew.svg +5 -0
  79. package/src/assets/svg/icons/IconPalette.svg +5 -0
  80. package/src/assets/svg/icons/IconPaypal.svg +5 -0
  81. package/src/assets/svg/icons/IconPerson.svg +5 -0
  82. package/src/assets/svg/icons/IconPhotoCamera.svg +5 -0
  83. package/src/assets/svg/icons/IconPinterest.svg +5 -0
  84. package/src/assets/svg/icons/IconPlayArrow.svg +3 -0
  85. package/src/assets/svg/icons/IconRemove.svg +3 -0
  86. package/src/assets/svg/icons/IconRoundedCorners.svg +5 -0
  87. package/src/assets/svg/icons/IconRuler.svg +3 -0
  88. package/src/assets/svg/icons/IconSearch.svg +5 -0
  89. package/src/assets/svg/icons/IconSeating.svg +3 -0
  90. package/src/assets/svg/icons/IconSell.svg +5 -0
  91. package/src/assets/svg/icons/IconShare.svg +5 -0
  92. package/src/assets/svg/icons/IconShoppingCart.svg +5 -0
  93. package/src/assets/svg/icons/IconSms.svg +5 -0
  94. package/src/assets/svg/icons/IconStar.svg +5 -0
  95. package/src/assets/svg/icons/IconSwapVert.svg +5 -0
  96. package/src/assets/svg/icons/IconThreeDRotation.svg +18 -0
  97. package/src/assets/svg/icons/IconTrophy.svg +5 -0
  98. package/src/assets/svg/icons/IconTune.svg +5 -0
  99. package/src/assets/svg/icons/IconTwitter.svg +5 -0
  100. package/src/assets/svg/icons/IconVideocam.svg +5 -0
  101. package/src/assets/svg/icons/IconViewInAr.svg +5 -0
  102. package/src/assets/svg/icons/IconVisibility.svg +5 -0
  103. package/src/assets/svg/icons/IconVolumeOff.svg +5 -0
  104. package/src/assets/svg/icons/IconVolumeOn.svg +5 -0
  105. package/src/assets/svg/icons/IconWarning.svg +5 -0
  106. package/src/assets/svg/icons/IconWeight.svg +3 -0
  107. package/src/assets/svg/icons/IconWidth.svg +3 -0
  108. package/src/assets/svg/icons/IconYoutube.svg +5 -0
  109. package/src/components/TideAccordionItem.vue +105 -0
  110. package/src/components/TideAlert.vue +124 -0
  111. package/src/components/TideBackgroundImage.vue +44 -0
  112. package/src/components/TideBadge.vue +30 -0
  113. package/src/components/TideBadgePremium.vue +31 -0
  114. package/src/components/TideBadgeTrustedPartner.vue +38 -0
  115. package/src/components/TideBreadCrumbs.vue +53 -0
  116. package/src/components/TideButton.vue +67 -0
  117. package/src/components/TideButtonIcon.vue +52 -0
  118. package/src/components/TideButtonPagination.vue +71 -0
  119. package/src/components/TideCard.vue +19 -0
  120. package/src/components/TideCarousel.vue +188 -0
  121. package/src/components/TideChipAction.vue +48 -0
  122. package/src/components/TideChipFilter.vue +55 -0
  123. package/src/components/TideChipInput.vue +44 -0
  124. package/src/components/TideColumns.vue +53 -0
  125. package/src/components/TideDivider.vue +24 -0
  126. package/src/components/TideIcon.vue +58 -0
  127. package/src/components/TideImage.vue +44 -0
  128. package/src/components/TideIndicator.vue +57 -0
  129. package/src/components/TideInputCheckbox.vue +145 -0
  130. package/src/components/TideInputRadio.vue +87 -0
  131. package/src/components/TideInputSelect.vue +204 -0
  132. package/src/components/TideInputText.vue +292 -0
  133. package/src/components/TideInputTextarea.vue +196 -0
  134. package/src/components/TideLink.vue +66 -0
  135. package/src/components/TideModal.vue +187 -0
  136. package/src/components/TidePagination.vue +67 -0
  137. package/src/components/TideSeoLinks.vue +58 -0
  138. package/src/components/TideTabs.vue +89 -0
  139. package/src/components/TideToggle.vue +95 -0
  140. package/src/docs/development.md +51 -0
  141. package/src/docs/integration.md +79 -0
  142. package/src/docs/storybook.md +39 -0
  143. package/src/stories/DemoCssUtilities.stories.ts +154 -0
  144. package/src/stories/DemoCssUtilitiesByTextInput.stories.ts +61 -0
  145. package/src/stories/FoundationsBorder.stories.ts +230 -0
  146. package/src/stories/FoundationsGap.stories.ts +180 -0
  147. package/src/stories/FoundationsMargin.stories.ts +155 -0
  148. package/src/stories/FoundationsPadding.stories.ts +108 -0
  149. package/src/stories/FoundationsShadow.stories.ts +84 -0
  150. package/src/stories/FoundationsTypography.stories.ts +172 -0
  151. package/src/stories/Template.stories.ts +71 -0
  152. package/src/stories/TideAccordionItem.stories.ts +68 -0
  153. package/src/stories/TideAlert.stories.ts +58 -0
  154. package/src/stories/TideBackgroundImage.stories.ts +53 -0
  155. package/src/stories/TideBadge.stories.ts +31 -0
  156. package/src/stories/TideBadgePremium.stories.ts +31 -0
  157. package/src/stories/TideBadgeTrustedPartner.stories.ts +33 -0
  158. package/src/stories/TideBreadCrumbs.stories.ts +43 -0
  159. package/src/stories/TideButton.stories.ts +118 -0
  160. package/src/stories/TideButtonIcon.stories.ts +103 -0
  161. package/src/stories/TideButtonPagination.stories.ts +99 -0
  162. package/src/stories/TideCard.stories.ts +38 -0
  163. package/src/stories/TideCarousel.stories.ts +130 -0
  164. package/src/stories/TideChipAction.stories.ts +46 -0
  165. package/src/stories/TideChipFilter.stories.ts +59 -0
  166. package/src/stories/TideChipInput.stories.ts +42 -0
  167. package/src/stories/TideColumns.stories.ts +90 -0
  168. package/src/stories/TideDivider.stories.ts +46 -0
  169. package/src/stories/TideIcon.stories.ts +29 -0
  170. package/src/stories/TideIndicator.stories.ts +31 -0
  171. package/src/stories/TideInputCheckbox.stories.ts +86 -0
  172. package/src/stories/TideInputRadio.stories.ts +71 -0
  173. package/src/stories/TideInputSelect.stories.ts +145 -0
  174. package/src/stories/TideInputText.stories.ts +181 -0
  175. package/src/stories/TideInputTextarea.stories.ts +116 -0
  176. package/src/stories/TideLink.stories.ts +137 -0
  177. package/src/stories/TideModal.stories.ts +122 -0
  178. package/src/stories/TidePagination.stories.ts +83 -0
  179. package/src/stories/TideSeoLinks.stories.ts +67 -0
  180. package/src/stories/TideTabs.stories.ts +100 -0
  181. package/src/stories/TideToggle.stories.ts +69 -0
  182. package/src/stories/Welcome.mdx +17 -0
  183. package/src/types/Alert.ts +8 -0
  184. package/src/types/Badge.ts +21 -0
  185. package/src/types/BreadCrumb.ts +5 -0
  186. package/src/types/Detail.ts +4 -0
  187. package/src/types/Element.ts +13 -0
  188. package/src/types/FacetRange.ts +84 -0
  189. package/src/types/Field.ts +54 -0
  190. package/src/types/Form.ts +58 -0
  191. package/src/types/Formatted.ts +22 -0
  192. package/src/types/Icon.ts +87 -0
  193. package/src/types/Link.ts +5 -0
  194. package/src/types/ListingMedia.ts +43 -0
  195. package/src/types/Orientation.ts +6 -0
  196. package/src/types/Priority.ts +11 -0
  197. package/src/types/Raw.ts +5 -0
  198. package/src/types/Realm.ts +13 -0
  199. package/src/types/RealmConfig.ts +14 -0
  200. package/src/types/Select.ts +10 -0
  201. package/src/types/Size.ts +6 -0
  202. package/src/types/Storybook.ts +219 -0
  203. package/src/types/Styles.ts +590 -0
  204. package/src/types/Tab.ts +5 -0
  205. package/src/types/Target.ts +6 -0
  206. package/src/types/TextInput.ts +16 -0
  207. package/src/types/Validation.ts +24 -0
  208. package/src/utilities/format.ts +184 -0
  209. package/src/utilities/storybook.ts +295 -0
  210. package/src/utilities/validation.ts +197 -0
  211. package/tests/utilities-format.spec.ts +430 -0
  212. package/tsconfig.app.json +14 -0
  213. package/tsconfig.config.json +12 -0
  214. package/tsconfig.json +22 -0
  215. package/tsconfig.vitest.json +10 -0
  216. package/vite.config.ts +43 -0
@@ -0,0 +1,181 @@
1
+ import { action } from '@storybook/addon-actions';
2
+
3
+ import * as STANDARD_FORMAT from '@/types/Formatted';
4
+ import * as STANDARD_ICON from '@/types/Icon';
5
+ import * as STANDARD_TEXT_INPUT_TYPE from '@/types/TextInput';
6
+ import TideInputText from '@/components/TideInputText.vue';
7
+ import { VALIDATOR } from '@/types/Validation';
8
+ import {
9
+ argTypeBooleanUnrequired,
10
+ dataTrack,
11
+ formatArgType,
12
+ formatArgTypeCheck,
13
+ parameters,
14
+ prependNoneAsUndefined,
15
+ } from '@/utilities/storybook';
16
+
17
+ const FORMAT = prependNoneAsUndefined(STANDARD_FORMAT.FORMAT);
18
+ const ICON = prependNoneAsUndefined(STANDARD_ICON.ICON);
19
+ const TEXT_INPUT_TYPE = prependNoneAsUndefined(STANDARD_TEXT_INPUT_TYPE.TEXT_INPUT_TYPE);
20
+
21
+ const render = (args: any, context: any) => ({
22
+ components: { TideInputText },
23
+ methods: {
24
+ handleChange: (event: KeyboardEvent) => {
25
+ const input = context.canvasElement.querySelector('input');
26
+
27
+ action('TideInputText changed')(event);
28
+ context.updateArgs({ ...args, value: input.value });
29
+ },
30
+ },
31
+ setup: () => ({ args }),
32
+ template: `<TideInputText @change="handleChange" v-bind="args" />`,
33
+ });
34
+
35
+ export default {
36
+ argTypes: {
37
+ autocomplete: {
38
+ ...argTypeBooleanUnrequired,
39
+ description: 'Determines whether browser attempts to autocomplete',
40
+ },
41
+ dataTrack,
42
+ disabled: {
43
+ ...argTypeBooleanUnrequired,
44
+ description: 'Determines whether input is interactable',
45
+ },
46
+ error: {
47
+ ...argTypeBooleanUnrequired,
48
+ description: 'Reflects whether the input value is valid',
49
+ },
50
+ hasClear: {
51
+ ...argTypeBooleanUnrequired,
52
+ description: 'Determines whether browser attempts to autocomplete',
53
+ if: { arg: 'type', neq: TEXT_INPUT_TYPE.PASSWORD },
54
+ },
55
+ iconLeading: {
56
+ ...formatArgType({ ICON }),
57
+ description: 'Icon at left of input value',
58
+ },
59
+ inputId: {
60
+ control: 'text',
61
+ description: 'Unique ID attribute<br />(to bind input label to input)',
62
+ table: {
63
+ defaultValue: { summary: 'None' },
64
+ type: { summary: 'string' },
65
+ },
66
+ },
67
+ label: {
68
+ control: 'text',
69
+ description: 'Label content',
70
+ table: {
71
+ defaultValue: { summary: 'None' },
72
+ type: { summary: 'string' },
73
+ },
74
+ },
75
+ maxlength: {
76
+ control: 'text',
77
+ description: 'Applies a maximum character count to the input',
78
+ table: {
79
+ defaultValue: { summary: 'None' },
80
+ type: { summary: 'number' },
81
+ },
82
+ },
83
+ minlength: {
84
+ control: 'text',
85
+ description: 'Applies a minimum character count to the input',
86
+ table: {
87
+ defaultValue: { summary: 'None' },
88
+ type: { summary: 'number' },
89
+ },
90
+ },
91
+ name: {
92
+ control: 'text',
93
+ description: 'Name attribute',
94
+ table: {
95
+ defaultValue: { summary: 'None' },
96
+ type: { summary: 'string' },
97
+ },
98
+ },
99
+ prefix: {
100
+ control: 'text',
101
+ description: 'input prefix',
102
+ table: {
103
+ defaultValue: { summary: 'None' },
104
+ type: { summary: 'string' },
105
+ },
106
+ },
107
+ required: {
108
+ ...argTypeBooleanUnrequired,
109
+ description: 'Determines whether input is required',
110
+ },
111
+ suffix: {
112
+ control: 'text',
113
+ description: 'input suffix<br />(i.e. units)',
114
+ table: {
115
+ defaultValue: { summary: 'None' },
116
+ type: { summary: 'string' },
117
+ },
118
+ },
119
+ supportingText: {
120
+ control: 'text',
121
+ description: 'Explainer text beneath input',
122
+ table: {
123
+ defaultValue: { summary: 'None' },
124
+ type: { summary: 'string' },
125
+ },
126
+ },
127
+ transformValue: {
128
+ ...formatArgType({ FORMAT }),
129
+ description: 'Determines text formatting applied to input value upon invoking relevant listener event(s)',
130
+ },
131
+ type: {
132
+ ...formatArgType({ TEXT_INPUT_TYPE }),
133
+ description: 'Determines the type(s) of values expected by the input',
134
+ },
135
+ updateValue: {
136
+ table: {
137
+ disable: true,
138
+ },
139
+ },
140
+ validators: {
141
+ ...formatArgTypeCheck({ VALIDATOR }),
142
+ description: 'Determines method(s) used to check for valid input value upon invoking relevant listener event(s)',
143
+ },
144
+ value: {
145
+ control: 'text',
146
+ description: 'input value',
147
+ table: {
148
+ defaultValue: { summary: 'None' },
149
+ type: { summary: 'string' },
150
+ },
151
+ },
152
+ },
153
+ args: {
154
+ autocomplete: undefined,
155
+ dataTrack: '',
156
+ disabled: undefined,
157
+ error: undefined,
158
+ hasClear: undefined,
159
+ iconLeading: undefined,
160
+ inputId: '',
161
+ label: 'Input label',
162
+ maxlength: '',
163
+ minlength: '',
164
+ name: '',
165
+ prefix: '',
166
+ required: undefined,
167
+ suffix: '',
168
+ supportingText: '',
169
+ transformValue: undefined,
170
+ type: undefined,
171
+ validators: [],
172
+ value: '',
173
+ },
174
+ component: TideInputText,
175
+ parameters,
176
+ render,
177
+ tags: ['autodocs'],
178
+ title: 'Basic Components/TideInputText',
179
+ };
180
+
181
+ export const Demo = {};
@@ -0,0 +1,116 @@
1
+ import { action } from '@storybook/addon-actions';
2
+
3
+ import TideInputTextarea from '@/components/TideInputTextarea.vue';
4
+ import { argTypeBooleanUnrequired, dataTrack, parameters } from '@/utilities/storybook';
5
+
6
+ const render = (args: any, context: any) => ({
7
+ components: { TideInputTextarea },
8
+ methods: {
9
+ handleChange: (event: KeyboardEvent) => {
10
+ const input = context.canvasElement.querySelector('textarea');
11
+
12
+ action('TideInputTextarea changed')(event);
13
+ context.updateArgs({ ...args, value: input.value });
14
+ },
15
+ },
16
+ setup: () => ({ args }),
17
+ template: `<TideInputTextarea @change="handleChange" v-bind="args" />`,
18
+ });
19
+
20
+ export default {
21
+ argTypes: {
22
+ dataTrack,
23
+ error: {
24
+ ...argTypeBooleanUnrequired,
25
+ description: 'Reflects whether the input value is valid',
26
+ },
27
+ inputId: {
28
+ control: 'text',
29
+ description: 'Unique ID attribute<br />(to bind input label to input)',
30
+ table: {
31
+ defaultValue: { summary: 'None' },
32
+ type: { summary: 'string' },
33
+ },
34
+ },
35
+ label: {
36
+ control: 'text',
37
+ description: 'Label content',
38
+ table: {
39
+ defaultValue: { summary: 'None' },
40
+ type: { summary: 'string' },
41
+ },
42
+ },
43
+ maxlength: {
44
+ control: 'text',
45
+ description: 'Applies a maximum character count to the input',
46
+ table: {
47
+ defaultValue: { summary: 'None' },
48
+ type: { summary: 'number' },
49
+ },
50
+ },
51
+ minlength: {
52
+ control: 'text',
53
+ description: 'Applies a minimum character count to the input',
54
+ table: {
55
+ defaultValue: { summary: 'None' },
56
+ type: { summary: 'number' },
57
+ },
58
+ },
59
+ name: {
60
+ control: 'text',
61
+ description: 'Name attribute',
62
+ table: {
63
+ defaultValue: { summary: 'None' },
64
+ type: { summary: 'string' },
65
+ },
66
+ },
67
+ required: {
68
+ ...argTypeBooleanUnrequired,
69
+ description: 'Determines whether input is required',
70
+ },
71
+ rows: {
72
+ control: 'text',
73
+ description: 'Determines the height of the input',
74
+ table: {
75
+ defaultValue: { summary: 'None' },
76
+ type: { summary: 'number' },
77
+ },
78
+ },
79
+ supportingText: {
80
+ control: 'text',
81
+ description: 'Explainer text beneath input',
82
+ table: {
83
+ defaultValue: { summary: 'None' },
84
+ type: { summary: 'string' },
85
+ },
86
+ },
87
+ value: {
88
+ control: 'text',
89
+ description: 'input value',
90
+ table: {
91
+ defaultValue: { summary: 'None' },
92
+ type: { summary: 'string' },
93
+ },
94
+ },
95
+ },
96
+ args: {
97
+ dataTrack: '',
98
+ error: undefined,
99
+ inputId: '',
100
+ label: 'Input label',
101
+ maxlength: '',
102
+ minlength: '',
103
+ name: '',
104
+ required: undefined,
105
+ rows: undefined,
106
+ supportingText: '',
107
+ value: '',
108
+ },
109
+ component: TideInputTextarea,
110
+ parameters,
111
+ render,
112
+ tags: ['autodocs'],
113
+ title: 'Basic Components/TideInputTextarea',
114
+ };
115
+
116
+ export const Demo = {};
@@ -0,0 +1,137 @@
1
+ import { action } from '@storybook/addon-actions';
2
+
3
+ import type { StoryContext } from '@storybook/vue3';
4
+
5
+ import * as STANDARD_ELEMENT from '@/types/Element';
6
+ import * as STANDARD_ICON from '@/types/Icon';
7
+ import * as STANDARD_LINK_SIZE from '@/types/Storybook';
8
+ import TideLink from '@/components/TideLink.vue';
9
+ import {
10
+ argTypeBooleanUnrequired,
11
+ click,
12
+ dataTrack,
13
+ formatArgType,
14
+ formatValueAsConstant,
15
+ prependNoneAsUndefined,
16
+ } from '@/utilities/storybook';
17
+
18
+ const ELEMENT = prependNoneAsUndefined(STANDARD_ELEMENT.ELEMENT);
19
+ const ICON = prependNoneAsUndefined(STANDARD_ICON.ICON);
20
+ const LINK_SIZE = prependNoneAsUndefined(STANDARD_LINK_SIZE.LINK_SIZE);
21
+
22
+ const formatSnippet = (code: string, context: StoryContext) => {
23
+ const { args, argTypes } = context;
24
+
25
+ const argsWithValues: string[] = [];
26
+ const { element, iconLeading, iconTrailing } = args;
27
+
28
+ if (args.size !== undefined) argsWithValues.push(`:class="${args.size}"`);
29
+ if (args.dataTrack !== '') argsWithValues.push(`:data-track="${args.dataTrack}"`);
30
+ if (args.element !== undefined)
31
+ argsWithValues.push(`:element="${formatValueAsConstant({ element: element }, argTypes)}"`);
32
+ if (args.href !== undefined) argsWithValues.push(`:href="${args.href}"`);
33
+ if (args.iconLeading !== undefined)
34
+ argsWithValues.push(`:icon-leading="${formatValueAsConstant({ iconLeading }, argTypes)}"`);
35
+ if (args.iconTrailing !== undefined)
36
+ argsWithValues.push(`:icon-trailing="${formatValueAsConstant({ iconTrailing }, argTypes)}"`);
37
+ if (args.isNewTab !== undefined) argsWithValues.push(`:is-new-tab="${args.isNewTab}"`);
38
+ if (args.label !== undefined) argsWithValues.push(`:label="${args.label}"`);
39
+ if (args.click !== undefined) argsWithValues.push(`@click="${args.click}"`);
40
+
41
+ return `<TideLink ${argsWithValues.join(' ')} />`;
42
+ };
43
+
44
+ const parameters = {
45
+ docs: {
46
+ source: {
47
+ format: 'vue',
48
+ language: 'html',
49
+ transform: formatSnippet,
50
+ },
51
+ },
52
+ };
53
+
54
+ const render = (args: any) => ({
55
+ components: { TideLink },
56
+ methods: {
57
+ handleClick: (event: Event) => {
58
+ if (args.element !== ELEMENT.LINK && args.click) action(args.click)(event);
59
+ },
60
+ },
61
+ setup: () => ({ args }),
62
+ template: '<TideLink :class="args.size" @click="handleClick" v-bind="args" />',
63
+ });
64
+
65
+ export default {
66
+ argTypes: {
67
+ click: {
68
+ ...click,
69
+ if: { arg: 'element', eq: ELEMENT.BUTTON },
70
+ },
71
+ dataTrack,
72
+ element: {
73
+ ...formatArgType({ ELEMENT }),
74
+ description: 'HTML tag type',
75
+ table: {
76
+ defaultValue: { summary: 'LINK' },
77
+ type: { summary: 'Element' },
78
+ },
79
+ },
80
+ href: {
81
+ description: 'URL to open<br />(Link only)',
82
+ if: { arg: 'element', eq: ELEMENT.LINK },
83
+ table: {
84
+ defaultValue: { summary: 'None' },
85
+ type: { summary: 'string' },
86
+ },
87
+ },
88
+ iconLeading: {
89
+ ...formatArgType({ ICON }),
90
+ description: 'Icon to left of label',
91
+ },
92
+ iconTrailing: {
93
+ ...formatArgType({ ICON }),
94
+ description: 'Icon to right of label',
95
+ },
96
+ isNewTab: {
97
+ ...argTypeBooleanUnrequired,
98
+ description: 'Determines whether to target a new browser tab<br />(Link only)',
99
+ if: { arg: 'element', eq: ELEMENT.LINK },
100
+ },
101
+ label: {
102
+ control: 'text',
103
+ description: 'Link text',
104
+ table: {
105
+ defaultValue: { summary: 'None' },
106
+ type: { summary: 'string' },
107
+ },
108
+ },
109
+ size: {
110
+ control: 'select',
111
+ description: 'Link text size',
112
+ options: LINK_SIZE,
113
+ table: {
114
+ defaultValue: { summary: 'None' },
115
+ type: { summary: 'string' },
116
+ },
117
+ },
118
+ },
119
+ args: {
120
+ click: 'doSomething',
121
+ dataTrack: '',
122
+ element: undefined,
123
+ href: '/',
124
+ iconLeading: undefined,
125
+ iconTrailing: undefined,
126
+ isNewTab: undefined,
127
+ label: 'Demo',
128
+ size: undefined,
129
+ },
130
+ component: TideLink,
131
+ parameters,
132
+ render,
133
+ tags: ['autodocs'],
134
+ title: 'Basic Components/TideLink',
135
+ };
136
+
137
+ export const Demo = {};
@@ -0,0 +1,122 @@
1
+ import { action } from '@storybook/addon-actions';
2
+
3
+ import type { StoryContext } from '@storybook/vue3';
4
+
5
+ import TideButton from '@/components/TideButton.vue';
6
+ import TideModal from '@/components/TideModal.vue';
7
+ import { disabledArgType, doSomething, lineBreak, tab } from '@/utilities/storybook';
8
+
9
+ const formatSnippet = (code: string, context: StoryContext) => {
10
+ const { args } = context;
11
+
12
+ const slotContentIndentationFixed = (args.default as string).replace(/(<\/[^>]+>)$/, `${tab}$1`);
13
+
14
+ return (
15
+ `<TideModal @close="handleClose">${lineBreak}` +
16
+ `${tab}${slotContentIndentationFixed}${lineBreak}${lineBreak}` +
17
+ `${tab}<template #footer>${lineBreak}` +
18
+ `${tab}${tab}${args.footer}${lineBreak}` +
19
+ `${tab}</template>${lineBreak}` +
20
+ `</TideModal>`
21
+ );
22
+ };
23
+
24
+ const parameters = {
25
+ docs: {
26
+ source: {
27
+ format: 'vue',
28
+ language: 'html',
29
+ transform: formatSnippet,
30
+ },
31
+ },
32
+ };
33
+
34
+ const render = (args: any, { updateArgs }: any) => ({
35
+ components: { TideButton, TideModal },
36
+ methods: {
37
+ doSomething,
38
+ handleClose: (event: Event) => {
39
+ updateArgs({ ...args, isOpen: false });
40
+ action('Modal closed')(event);
41
+
42
+ try {
43
+ const callback = eval(args.handleClose);
44
+ if (callback) {
45
+ callback();
46
+ }
47
+ } catch {
48
+ alert('Please specify a valid function in the "close" control.');
49
+ }
50
+ },
51
+ },
52
+ setup: () => ({ args }),
53
+ template: `
54
+ <p>Toggle "isOpen" prop below to preview.</p>
55
+ <TideModal v-bind="args" @close="handleClose">
56
+ ${args.default}
57
+ <template #footer>${args.footer}</template>
58
+ </TideModal>`,
59
+ });
60
+
61
+ export default {
62
+ argTypes: {
63
+ close: disabledArgType,
64
+ default: {
65
+ control: 'text',
66
+ description: 'Modal content',
67
+ table: {
68
+ defaultValue: { summary: 'None' },
69
+ type: { summary: 'HTML' },
70
+ },
71
+ },
72
+ footer: {
73
+ control: 'text',
74
+ description: 'Footer content',
75
+ table: {
76
+ defaultValue: { summary: 'None' },
77
+ type: { summary: 'HTML' },
78
+ },
79
+ },
80
+ handleClose: {
81
+ control: 'text',
82
+ description: 'JS function to execute when modal is closed',
83
+ table: {
84
+ defaultValue: { summary: 'None' },
85
+ type: { summary: '(event: Event) => void' },
86
+ },
87
+ },
88
+ isOpen: {
89
+ description: 'Determines whether the Modal is displayed',
90
+ table: {
91
+ defaultValue: { summary: 'False' },
92
+ },
93
+ },
94
+ title: {
95
+ description: 'Modal title',
96
+ table: {
97
+ defaultValue: { summary: 'None' },
98
+ },
99
+ },
100
+ width: {
101
+ description: 'Applies width to Modal<br />(include units)',
102
+ table: {
103
+ defaultValue: { summary: 'None' },
104
+ },
105
+ },
106
+ },
107
+ args: {
108
+ default: `<div>${lineBreak}${tab}Default Slot Demo${lineBreak}</div>`,
109
+ footer: '<TideButton label="Footer Slot Demo" />',
110
+ handleClose: 'doSomething',
111
+ isOpen: false,
112
+ title: 'Modal Demo',
113
+ width: '400px',
114
+ },
115
+ component: TideModal,
116
+ parameters,
117
+ render,
118
+ tags: ['autodocs'],
119
+ title: 'Basic Components/TideModal',
120
+ };
121
+
122
+ export const Demo = {};
@@ -0,0 +1,83 @@
1
+ import { action } from '@storybook/addon-actions';
2
+
3
+ import * as STANDARD_ELEMENT from '@/types/Element';
4
+ import TidePagination from '@/components/TidePagination.vue';
5
+ import {
6
+ argTypeBooleanUnrequired,
7
+ change,
8
+ disabledArgType,
9
+ doSomething,
10
+ parameters,
11
+ prependNoneAsUndefined,
12
+ } from '@/utilities/storybook';
13
+
14
+ const ELEMENT_TEXT_AS_ICON = prependNoneAsUndefined(STANDARD_ELEMENT.ELEMENT_TEXT_AS_ICON);
15
+
16
+ const render = (args: any, { updateArgs }: any) => ({
17
+ components: { TidePagination },
18
+ methods: {
19
+ doSomething,
20
+ handleEmit: (event: Event, index: number) => {
21
+ action(`Current page ${index}`)(event, { index });
22
+
23
+ updateArgs({ ...args, pageCurrent: index });
24
+
25
+ try {
26
+ const performCallback = eval(args.handleEmit);
27
+
28
+ if (performCallback) {
29
+ performCallback();
30
+ }
31
+ } catch {
32
+ alert('Please specify a valid handler in the "change" control.');
33
+ }
34
+ },
35
+ },
36
+ setup: () => ({ args }),
37
+ template: `<TidePagination @change="handleEmit" v-bind="args" />`,
38
+ });
39
+
40
+ export default {
41
+ argTypes: {
42
+ change: disabledArgType,
43
+ disabled: {
44
+ ...argTypeBooleanUnrequired,
45
+ description: 'Determines clickability<br />(Button only)',
46
+ if: {
47
+ arg: 'element',
48
+ eq: ELEMENT_TEXT_AS_ICON.BUTTON,
49
+ },
50
+ },
51
+ handleEmit: {
52
+ ...change,
53
+ table: {
54
+ defaultValue: { summary: 'None' },
55
+ type: { summary: '(event: Event, pageIndex: number) => void' },
56
+ },
57
+ },
58
+ pageCurrent: {
59
+ control: {
60
+ min: 1,
61
+ type: 'number',
62
+ },
63
+ },
64
+ pageTotal: {
65
+ control: {
66
+ min: 1,
67
+ type: 'number',
68
+ },
69
+ },
70
+ },
71
+ args: {
72
+ handleEmit: 'doSomething',
73
+ pageCurrent: 1,
74
+ pageTotal: 5,
75
+ },
76
+ component: TidePagination,
77
+ parameters,
78
+ render,
79
+ tags: ['autodocs'],
80
+ title: 'Basic Components/TidePagination',
81
+ };
82
+
83
+ export const Demo = {};
@@ -0,0 +1,67 @@
1
+ import type { StoryContext } from '@storybook/vue3';
2
+
3
+ import type { Link } from '@/types/Link';
4
+
5
+ import TideSeoLinks from '@/components/TideSeoLinks.vue';
6
+
7
+ const links: Link[] = new Array(12).fill({}).map((link, index) => {
8
+ return {
9
+ isNewTab: false,
10
+ label: `Link ${index + 1}`,
11
+ url: '/',
12
+ };
13
+ });
14
+
15
+ const formatSnippet = (code: string, context: StoryContext) => {
16
+ const { args } = context;
17
+
18
+ return `<TideSeoLinks :heading="${args.heading}" :link="links" />`;
19
+ };
20
+
21
+ const parameters = {
22
+ docs: {
23
+ source: {
24
+ format: 'vue',
25
+ language: 'html',
26
+ transform: formatSnippet,
27
+ },
28
+ },
29
+ };
30
+
31
+ const render = (args: any) => ({
32
+ components: { TideSeoLinks },
33
+ setup: () => ({ args }),
34
+ template: '<TideSeoLinks v-bind="args" />',
35
+ });
36
+
37
+ export default {
38
+ argTypes: {
39
+ heading: {
40
+ control: 'text',
41
+ description: 'Determines label, URL, and target for each link',
42
+ table: {
43
+ defaultValue: { summary: 'None' },
44
+ type: { summary: 'Link[]' },
45
+ },
46
+ },
47
+ links: {
48
+ control: 'object',
49
+ description: 'Determines label, URL, and target for each link',
50
+ table: {
51
+ defaultValue: { summary: 'None' },
52
+ type: { summary: 'Link[]' },
53
+ },
54
+ },
55
+ },
56
+ args: {
57
+ heading: 'Demo',
58
+ links,
59
+ },
60
+ component: TideSeoLinks,
61
+ parameters,
62
+ render,
63
+ tags: ['autodocs'],
64
+ title: 'Basic Components/TideSeoLinks',
65
+ };
66
+
67
+ export const Demo = {};