@gitlab/ui 77.2.0 → 77.4.0

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 (38) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +10 -3
  3. package/dist/components/base/sorting/sorting.js +1 -4
  4. package/dist/index.css +2 -2
  5. package/dist/index.css.map +1 -1
  6. package/dist/tokens/common_story_options.js +28 -68
  7. package/dist/tokens/css/tokens.css +1 -1
  8. package/dist/tokens/css/tokens.dark.css +1 -1
  9. package/dist/tokens/js/tokens.dark.js +1 -1
  10. package/dist/tokens/js/tokens.js +1 -1
  11. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  12. package/dist/tokens/scss/_tokens.scss +1 -1
  13. package/dist/tokens/tokens_story.js +83 -0
  14. package/dist/utility_classes.css +1 -1
  15. package/dist/utility_classes.css.map +1 -1
  16. package/package.json +1 -1
  17. package/src/components/base/button/button.stories.js +0 -30
  18. package/src/components/base/button_group/button_group.md +22 -0
  19. package/src/components/base/button_group/button_group.stories.js +92 -12
  20. package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +1 -1
  21. package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +8 -1
  22. package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.md +13 -9
  23. package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.scss +0 -32
  24. package/src/components/base/new_dropdowns/dropdown.scss +58 -2
  25. package/src/components/base/new_dropdowns/listbox/listbox.md +19 -15
  26. package/src/components/base/sorting/sorting.vue +1 -9
  27. package/src/scss/utilities.scss +12 -0
  28. package/src/scss/utility-mixins/flex.scss +6 -0
  29. package/src/tokens/color.dark.tokens.stories.js +8 -38
  30. package/src/tokens/color.data_viz.dark.tokens.stories.js +7 -27
  31. package/src/tokens/color.data_viz.tokens.stories.js +7 -27
  32. package/src/tokens/color.theme.dark.tokens.stories.js +8 -32
  33. package/src/tokens/color.theme.tokens.stories.js +8 -32
  34. package/src/tokens/color.tokens.stories.js +8 -38
  35. package/src/tokens/color.transparency.tokens.stories.js +5 -14
  36. package/src/tokens/common_story_options.js +21 -67
  37. package/src/tokens/text.tokens.stories.js +4 -7
  38. package/src/tokens/tokens_story.vue +73 -0
@@ -1,37 +1,17 @@
1
1
  import COMPILED_TOKENS from '../../dist/tokens/json/tokens.dark.json';
2
- import { colorTokenStoryOptions } from './common_story_options';
2
+ import { createDesignTokenStory } from './common_story_options';
3
3
 
4
- const generateProps = ({ tokens = {} } = {}) => ({ tokens });
4
+ export const DataVizGreen = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].green });
5
5
 
6
- export const DataVizGreen = (args, { argTypes }) => ({
7
- props: Object.keys(argTypes),
8
- ...colorTokenStoryOptions,
9
- });
10
- DataVizGreen.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].green });
6
+ export const DataVizAqua = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].aqua });
11
7
 
12
- export const DataVizAqua = (args, { argTypes }) => ({
13
- props: Object.keys(argTypes),
14
- ...colorTokenStoryOptions,
15
- });
16
- DataVizAqua.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].aqua });
8
+ export const DataVizBlue = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].blue });
17
9
 
18
- export const DataVizBlue = (args, { argTypes }) => ({
19
- props: Object.keys(argTypes),
20
- ...colorTokenStoryOptions,
10
+ export const DataVizMagenta = createDesignTokenStory({
11
+ tokens: COMPILED_TOKENS['data-viz'].magenta,
21
12
  });
22
- DataVizBlue.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].blue });
23
13
 
24
- export const DataVizMagenta = (args, { argTypes }) => ({
25
- props: Object.keys(argTypes),
26
- ...colorTokenStoryOptions,
27
- });
28
- DataVizMagenta.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].magenta });
29
-
30
- export const DataVizOrange = (args, { argTypes }) => ({
31
- props: Object.keys(argTypes),
32
- ...colorTokenStoryOptions,
33
- });
34
- DataVizOrange.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].orange });
14
+ export const DataVizOrange = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].orange });
35
15
 
36
16
  // eslint-disable-next-line storybook/csf-component
37
17
  export default {
@@ -1,37 +1,17 @@
1
1
  import COMPILED_TOKENS from '../../dist/tokens/json/tokens.json';
2
- import { colorTokenStoryOptions } from './common_story_options';
2
+ import { createDesignTokenStory } from './common_story_options';
3
3
 
4
- const generateProps = ({ tokens = {} } = {}) => ({ tokens });
4
+ export const DataVizGreen = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].green });
5
5
 
6
- export const DataVizGreen = (args, { argTypes }) => ({
7
- props: Object.keys(argTypes),
8
- ...colorTokenStoryOptions,
9
- });
10
- DataVizGreen.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].green });
6
+ export const DataVizAqua = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].aqua });
11
7
 
12
- export const DataVizAqua = (args, { argTypes }) => ({
13
- props: Object.keys(argTypes),
14
- ...colorTokenStoryOptions,
15
- });
16
- DataVizAqua.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].aqua });
8
+ export const DataVizBlue = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].blue });
17
9
 
18
- export const DataVizBlue = (args, { argTypes }) => ({
19
- props: Object.keys(argTypes),
20
- ...colorTokenStoryOptions,
10
+ export const DataVizMagenta = createDesignTokenStory({
11
+ tokens: COMPILED_TOKENS['data-viz'].magenta,
21
12
  });
22
- DataVizBlue.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].blue });
23
13
 
24
- export const DataVizMagenta = (args, { argTypes }) => ({
25
- props: Object.keys(argTypes),
26
- ...colorTokenStoryOptions,
27
- });
28
- DataVizMagenta.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].magenta });
29
-
30
- export const DataVizOrange = (args, { argTypes }) => ({
31
- props: Object.keys(argTypes),
32
- ...colorTokenStoryOptions,
33
- });
34
- DataVizOrange.args = generateProps({ tokens: COMPILED_TOKENS['data-viz'].orange });
14
+ export const DataVizOrange = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].orange });
35
15
 
36
16
  // eslint-disable-next-line storybook/csf-component
37
17
  export default {
@@ -1,43 +1,19 @@
1
1
  import COMPILED_TOKENS from '../../dist/tokens/json/tokens.dark.json';
2
- import { colorTokenStoryOptions } from './common_story_options';
2
+ import { createDesignTokenStory } from './common_story_options';
3
3
 
4
- const generateProps = ({ tokens = {} } = {}) => ({ tokens });
4
+ export const ThemeIndigo = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.indigo });
5
5
 
6
- export const ThemeIndigo = (args, { argTypes }) => ({
7
- props: Object.keys(argTypes),
8
- ...colorTokenStoryOptions,
9
- });
10
- ThemeIndigo.args = generateProps({ tokens: COMPILED_TOKENS.theme.indigo });
11
-
12
- export const ThemeBlue = (args, { argTypes }) => ({
13
- props: Object.keys(argTypes),
14
- ...colorTokenStoryOptions,
15
- });
16
- ThemeBlue.args = generateProps({ tokens: COMPILED_TOKENS.theme.blue });
6
+ export const ThemeBlue = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.blue });
17
7
 
18
- export const ThemeLightBlue = (args, { argTypes }) => ({
19
- props: Object.keys(argTypes),
20
- ...colorTokenStoryOptions,
8
+ export const ThemeLightBlue = createDesignTokenStory({
9
+ tokens: COMPILED_TOKENS.theme['light-blue'],
21
10
  });
22
- ThemeLightBlue.args = generateProps({ tokens: COMPILED_TOKENS.theme['light-blue'] });
23
11
 
24
- export const ThemeGreen = (args, { argTypes }) => ({
25
- props: Object.keys(argTypes),
26
- ...colorTokenStoryOptions,
27
- });
28
- ThemeGreen.args = generateProps({ tokens: COMPILED_TOKENS.theme.green });
12
+ export const ThemeGreen = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.green });
29
13
 
30
- export const ThemeRed = (args, { argTypes }) => ({
31
- props: Object.keys(argTypes),
32
- ...colorTokenStoryOptions,
33
- });
34
- ThemeRed.args = generateProps({ tokens: COMPILED_TOKENS.theme.red });
14
+ export const ThemeRed = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.red });
35
15
 
36
- export const ThemeLightRed = (args, { argTypes }) => ({
37
- props: Object.keys(argTypes),
38
- ...colorTokenStoryOptions,
39
- });
40
- ThemeLightRed.args = generateProps({ tokens: COMPILED_TOKENS.theme['light-red'] });
16
+ export const ThemeLightRed = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme['light-red'] });
41
17
 
42
18
  // eslint-disable-next-line storybook/csf-component
43
19
  export default {
@@ -1,43 +1,19 @@
1
1
  import COMPILED_TOKENS from '../../dist/tokens/json/tokens.json';
2
- import { colorTokenStoryOptions } from './common_story_options';
2
+ import { createDesignTokenStory } from './common_story_options';
3
3
 
4
- const generateProps = ({ tokens = {} } = {}) => ({ tokens });
4
+ export const ThemeIndigo = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.indigo });
5
5
 
6
- export const ThemeIndigo = (args, { argTypes }) => ({
7
- props: Object.keys(argTypes),
8
- ...colorTokenStoryOptions,
9
- });
10
- ThemeIndigo.args = generateProps({ tokens: COMPILED_TOKENS.theme.indigo });
11
-
12
- export const ThemeBlue = (args, { argTypes }) => ({
13
- props: Object.keys(argTypes),
14
- ...colorTokenStoryOptions,
15
- });
16
- ThemeBlue.args = generateProps({ tokens: COMPILED_TOKENS.theme.blue });
6
+ export const ThemeBlue = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.blue });
17
7
 
18
- export const ThemeLightBlue = (args, { argTypes }) => ({
19
- props: Object.keys(argTypes),
20
- ...colorTokenStoryOptions,
8
+ export const ThemeLightBlue = createDesignTokenStory({
9
+ tokens: COMPILED_TOKENS.theme['light-blue'],
21
10
  });
22
- ThemeLightBlue.args = generateProps({ tokens: COMPILED_TOKENS.theme['light-blue'] });
23
11
 
24
- export const ThemeGreen = (args, { argTypes }) => ({
25
- props: Object.keys(argTypes),
26
- ...colorTokenStoryOptions,
27
- });
28
- ThemeGreen.args = generateProps({ tokens: COMPILED_TOKENS.theme.green });
12
+ export const ThemeGreen = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.green });
29
13
 
30
- export const ThemeRed = (args, { argTypes }) => ({
31
- props: Object.keys(argTypes),
32
- ...colorTokenStoryOptions,
33
- });
34
- ThemeRed.args = generateProps({ tokens: COMPILED_TOKENS.theme.red });
14
+ export const ThemeRed = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.red });
35
15
 
36
- export const ThemeLightRed = (args, { argTypes }) => ({
37
- props: Object.keys(argTypes),
38
- ...colorTokenStoryOptions,
39
- });
40
- ThemeLightRed.args = generateProps({ tokens: COMPILED_TOKENS.theme['light-red'] });
16
+ export const ThemeLightRed = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme['light-red'] });
41
17
 
42
18
  // eslint-disable-next-line storybook/csf-component
43
19
  export default {
@@ -1,54 +1,24 @@
1
1
  import COMPILED_TOKENS from '../../dist/tokens/json/tokens.json';
2
- import { colorTokenStoryOptions } from './common_story_options';
2
+ import { createDesignTokenStory } from './common_story_options';
3
3
 
4
- const generateProps = ({ tokens = {} } = {}) => ({ tokens });
5
-
6
- export const Default = (args, { argTypes }) => ({
7
- props: Object.keys(argTypes),
8
- ...colorTokenStoryOptions,
9
- });
10
- Default.args = generateProps({
4
+ export const Default = createDesignTokenStory({
11
5
  tokens: {
12
6
  white: COMPILED_TOKENS.white,
13
7
  black: COMPILED_TOKENS.black,
14
8
  },
15
9
  });
16
10
 
17
- export const Gray = (args, { argTypes }) => ({
18
- props: Object.keys(argTypes),
19
- ...colorTokenStoryOptions,
20
- });
21
- Gray.args = generateProps({ tokens: COMPILED_TOKENS.gray });
11
+ export const Gray = createDesignTokenStory({ tokens: COMPILED_TOKENS.gray });
22
12
 
23
- export const Blue = (args, { argTypes }) => ({
24
- props: Object.keys(argTypes),
25
- ...colorTokenStoryOptions,
26
- });
27
- Blue.args = generateProps({ tokens: COMPILED_TOKENS.blue });
13
+ export const Blue = createDesignTokenStory({ tokens: COMPILED_TOKENS.blue });
28
14
 
29
- export const Green = (args, { argTypes }) => ({
30
- props: Object.keys(argTypes),
31
- ...colorTokenStoryOptions,
32
- });
33
- Green.args = generateProps({ tokens: COMPILED_TOKENS.green });
15
+ export const Green = createDesignTokenStory({ tokens: COMPILED_TOKENS.green });
34
16
 
35
- export const Orange = (args, { argTypes }) => ({
36
- props: Object.keys(argTypes),
37
- ...colorTokenStoryOptions,
38
- });
39
- Orange.args = generateProps({ tokens: COMPILED_TOKENS.orange });
17
+ export const Orange = createDesignTokenStory({ tokens: COMPILED_TOKENS.orange });
40
18
 
41
- export const Red = (args, { argTypes }) => ({
42
- props: Object.keys(argTypes),
43
- ...colorTokenStoryOptions,
44
- });
45
- Red.args = generateProps({ tokens: COMPILED_TOKENS.red });
19
+ export const Red = createDesignTokenStory({ tokens: COMPILED_TOKENS.red });
46
20
 
47
- export const Purple = (args, { argTypes }) => ({
48
- props: Object.keys(argTypes),
49
- ...colorTokenStoryOptions,
50
- });
51
- Purple.args = generateProps({ tokens: COMPILED_TOKENS.purple });
21
+ export const Purple = createDesignTokenStory({ tokens: COMPILED_TOKENS.purple });
52
22
 
53
23
  // eslint-disable-next-line storybook/csf-component
54
24
  export default {
@@ -1,21 +1,12 @@
1
1
  import COMPILED_TOKENS from '../../dist/tokens/json/tokens.json';
2
- import { colorTokenStoryOptions } from './common_story_options';
2
+ import { createDesignTokenStory } from './common_story_options';
3
3
 
4
- const generateProps = ({ tokens = {} } = {}) => ({ tokens });
4
+ export const Gray = createDesignTokenStory({ tokens: COMPILED_TOKENS['t-gray-a'] });
5
5
 
6
- export const Gray = (args, { argTypes }) => ({
7
- props: Object.keys(argTypes),
8
- ...colorTokenStoryOptions,
6
+ export const White = createDesignTokenStory({
7
+ tokens: COMPILED_TOKENS['t-white-a'],
8
+ containerClass: 'gl-bg-gray-900 gl-text-white',
9
9
  });
10
- Gray.args = generateProps({ tokens: COMPILED_TOKENS['t-gray-a'] });
11
-
12
- export const White = (args, { argTypes }) => ({
13
- props: Object.keys(argTypes),
14
- components: colorTokenStoryOptions.components,
15
- methods: colorTokenStoryOptions.methods,
16
- template: `<div class="gl-bg-gray-900 gl-text-white">${colorTokenStoryOptions.template}</div>`,
17
- });
18
- White.args = generateProps({ tokens: COMPILED_TOKENS['t-white-a'] });
19
10
 
20
11
  // eslint-disable-next-line storybook/csf-component
21
12
  export default {
@@ -1,71 +1,25 @@
1
1
  import { WHITE, GRAY_950 } from '../../dist/tokens/js/tokens';
2
- import { colorFromBackground } from '../utils/utils';
3
- import GlColorContrast from '../internal/color_contrast/color_contrast.vue';
2
+ import TokensStory from './tokens_story.vue';
4
3
 
5
- export const components = {
6
- GlColorContrast,
7
- };
8
-
9
- export const methods = {
10
- isAlpha(value) {
11
- return value.startsWith('rgba(');
12
- },
13
- isBackgroundColor(property) {
14
- return property === 'backgroundColor';
15
- },
16
- getTokenName(token) {
17
- return token.path.filter(Boolean).join('.');
18
- },
19
- getClasses(property, value) {
20
- if (this.isAlpha(value)) return '';
21
- if (!this.isBackgroundColor(property)) return '';
22
- const textColorVariant = colorFromBackground(value, 4.5);
23
- return {
24
- 'gl-text-gray-950': textColorVariant === 'dark',
25
- 'gl-text-white': textColorVariant === 'light',
26
- };
27
- },
28
- getStyle(property, value) {
29
- if (this.isBackgroundColor(property)) {
30
- return { backgroundColor: value };
31
- }
32
- return { color: value };
33
- },
34
- };
35
-
36
- const colorTemplate = (
37
- property = 'backgroundColor',
38
- lightBackground = WHITE,
39
- darkBackground = GRAY_950
40
- ) => `
41
- <ul
42
- class="gl-list-style-none gl-m-0 gl-p-0"
43
- >
44
- <li
45
- v-for="token in tokens"
46
- :key="token.name"
47
- class="gl-display-flex gl-flex-wrap gl-align-items-center gl-justify-content-space-between gl-gap-3 gl-p-3"
48
- :class="getClasses('${property}', token.value)"
49
- :style="getStyle('${property}', token.value)"
50
- >
51
- <code class="gl-reset-color">{{ getTokenName(token) }}</code>
52
- <div class="gl-display-flex gl-align-items-center gl-gap-3">
53
- <code class="gl-reset-color">{{ token.value }}</code>
54
- <gl-color-contrast v-if="!isAlpha(token.value)" :foreground="token.value" background="${darkBackground}" />
55
- <gl-color-contrast v-if="!isAlpha(token.value)" :foreground="token.value" background="${lightBackground}" />
56
- </div>
57
- </li>
58
- </ul>
59
- `;
60
-
61
- export const colorTokenStoryOptions = {
62
- components,
63
- methods,
64
- template: colorTemplate('backgroundColor'),
65
- };
4
+ export const createDesignTokenStory = ({
5
+ tokens = {},
6
+ isBackgroundColorStory = true,
7
+ containerClass = '',
8
+ } = {}) => {
9
+ const Story = (args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: {
12
+ TokensStory,
13
+ },
14
+ provide: {
15
+ containerClass,
16
+ isBackgroundColorStory,
17
+ lightBackground: WHITE,
18
+ darkBackground: GRAY_950,
19
+ },
20
+ template: `<tokens-story v-bind="$props" />`,
21
+ });
22
+ Story.args = { tokens };
66
23
 
67
- export const colorTextTokenStoryOptions = {
68
- components,
69
- methods,
70
- template: colorTemplate('color'),
24
+ return Story;
71
25
  };
@@ -1,13 +1,10 @@
1
1
  import COMPILED_TOKENS from '../../dist/tokens/json/tokens.json';
2
- import { colorTextTokenStoryOptions } from './common_story_options';
2
+ import { createDesignTokenStory } from './common_story_options';
3
3
 
4
- const generateProps = ({ tokens = {} } = {}) => ({ tokens });
5
-
6
- export const Default = (args, { argTypes }) => ({
7
- props: Object.keys(argTypes),
8
- ...colorTextTokenStoryOptions,
4
+ export const Default = createDesignTokenStory({
5
+ tokens: COMPILED_TOKENS.text,
6
+ isBackgroundColorStory: false,
9
7
  });
10
- Default.args = generateProps({ name: 'text', tokens: COMPILED_TOKENS.text });
11
8
 
12
9
  // eslint-disable-next-line storybook/csf-component
13
10
  export default {
@@ -0,0 +1,73 @@
1
+ <script>
2
+ import { colorFromBackground } from '../utils/utils';
3
+ import GlColorContrast from '../internal/color_contrast/color_contrast.vue';
4
+
5
+ export default {
6
+ name: 'TokensStory',
7
+ components: {
8
+ GlColorContrast,
9
+ },
10
+ inject: ['isBackgroundColorStory', 'lightBackground', 'darkBackground', 'containerClass'],
11
+ props: {
12
+ tokens: {
13
+ type: Object,
14
+ required: false,
15
+ default: () => ({}),
16
+ },
17
+ },
18
+ methods: {
19
+ isAlpha(value) {
20
+ return value.startsWith('rgba(');
21
+ },
22
+ getTokenName(token) {
23
+ return token.path.filter(Boolean).join('.');
24
+ },
25
+ getClasses(value) {
26
+ if (this.isAlpha(value)) return '';
27
+ if (!this.isBackgroundColorStory) return '';
28
+
29
+ const textColorVariant = colorFromBackground(value, 4.5);
30
+ return {
31
+ 'gl-text-gray-950': textColorVariant === 'dark',
32
+ 'gl-text-white': textColorVariant === 'light',
33
+ };
34
+ },
35
+ getStyle(value) {
36
+ if (this.isBackgroundColorStory) {
37
+ return { backgroundColor: value };
38
+ }
39
+
40
+ return { color: value };
41
+ },
42
+ },
43
+ };
44
+ </script>
45
+
46
+ <template>
47
+ <div :class="containerClass">
48
+ <ul class="gl-list-style-none gl-m-0 gl-p-0">
49
+ <li
50
+ v-for="token in tokens"
51
+ :key="token.name"
52
+ class="gl-display-flex gl-flex-wrap gl-align-items-center gl-justify-content-space-between gl-gap-3 gl-p-3"
53
+ :class="getClasses(token.value)"
54
+ :style="getStyle(token.value)"
55
+ >
56
+ <code class="gl-reset-color">{{ getTokenName(token) }}</code>
57
+ <div class="gl-display-flex gl-align-items-center gl-gap-3">
58
+ <code class="gl-reset-color">{{ token.value }}</code>
59
+ <gl-color-contrast
60
+ v-if="!isAlpha(token.value)"
61
+ :foreground="token.value"
62
+ :background="darkBackground"
63
+ />
64
+ <gl-color-contrast
65
+ v-if="!isAlpha(token.value)"
66
+ :foreground="token.value"
67
+ :background="lightBackground"
68
+ />
69
+ </div>
70
+ </li>
71
+ </ul>
72
+ </div>
73
+ </template>