@gitlab/ui 40.6.5 → 40.7.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "40.6.5",
3
+ "version": "40.7.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -87,15 +87,15 @@
87
87
  "@rollup/plugin-commonjs": "^11.1.0",
88
88
  "@rollup/plugin-node-resolve": "^7.1.3",
89
89
  "@rollup/plugin-replace": "^2.3.2",
90
- "@storybook/addon-a11y": "6.5.5",
91
- "@storybook/addon-docs": "6.5.5",
92
- "@storybook/addon-essentials": "6.5.5",
90
+ "@storybook/addon-a11y": "6.5.6",
91
+ "@storybook/addon-docs": "6.5.6",
92
+ "@storybook/addon-essentials": "6.5.6",
93
93
  "@storybook/addon-knobs": "6.4.0",
94
- "@storybook/addon-storyshots": "6.5.5",
95
- "@storybook/addon-storyshots-puppeteer": "6.5.5",
96
- "@storybook/addon-viewport": "6.5.5",
97
- "@storybook/theming": "6.5.5",
98
- "@storybook/vue": "6.5.5",
94
+ "@storybook/addon-storyshots": "6.5.6",
95
+ "@storybook/addon-storyshots-puppeteer": "6.5.6",
96
+ "@storybook/addon-viewport": "6.5.6",
97
+ "@storybook/theming": "6.5.6",
98
+ "@storybook/vue": "6.5.6",
99
99
  "@vue/test-utils": "1.3.0",
100
100
  "autoprefixer": "^9.7.6",
101
101
  "babel-jest": "^26.6.3",
@@ -106,7 +106,7 @@
106
106
  "bootstrap": "4.5.3",
107
107
  "cypress": "^6.6.0",
108
108
  "emoji-regex": "^10.0.0",
109
- "eslint": "7.32.0",
109
+ "eslint": "8.16.0",
110
110
  "eslint-import-resolver-jest": "3.0.2",
111
111
  "eslint-plugin-cypress": "2.12.1",
112
112
  "eslint-plugin-storybook": "0.5.12",
@@ -202,8 +202,10 @@ const LabelToken = {
202
202
  },
203
203
  containerStyle() {
204
204
  if (this.activeLabel) {
205
+ // eslint-disable-next-line camelcase
205
206
  const { color, text_color } = this.activeLabel;
206
207
 
208
+ // eslint-disable-next-line camelcase
207
209
  return { backgroundColor: color, color: text_color };
208
210
  }
209
211
  return {};
@@ -22,7 +22,6 @@
22
22
  @include gl-line-height-normal;
23
23
  @include gl-font-weight-normal;
24
24
  @include gl-display-inline-flex;
25
- @include gl-flex-direction-column;
26
25
 
27
26
  &.is-disabled {
28
27
  @include gl-opacity-4;
@@ -109,18 +109,23 @@ describe('toggle', () => {
109
109
 
110
110
  describe('label position', () => {
111
111
  describe.each`
112
- state | labelPosition | hasGlSrOnlyClass
113
- ${'top'} | ${toggleLabelPosition.top} | ${false}
114
- ${'left'} | ${toggleLabelPosition.left} | ${false}
115
- ${'hidden'} | ${toggleLabelPosition.hidden} | ${true}
116
- `('when $state', ({ labelPosition, hasGlSrOnlyClass }) => {
112
+ state | labelPosition | hasGlSrOnlyClass | flexDirection
113
+ ${'top'} | ${toggleLabelPosition.top} | ${false} | ${'gl-flex-direction-column'}
114
+ ${'left'} | ${toggleLabelPosition.left} | ${false} | ${'gl-toggle-label-inline'}
115
+ ${'hidden'} | ${toggleLabelPosition.hidden} | ${true} | ${'gl-flex-direction-column'}
116
+ `('when $state', ({ labelPosition, hasGlSrOnlyClass, flexDirection }) => {
117
117
  beforeEach(() => {
118
118
  createWrapper({ labelPosition });
119
119
  });
120
120
 
121
+ it(`${flexDirection} class is added to the label`, () => {
122
+ const cssClasses = wrapper.find('[data-testid="toggle-wrapper"]').classes();
123
+
124
+ return expect(cssClasses).toContain(flexDirection);
125
+ });
126
+
121
127
  it(`${hasGlSrOnlyClass ? 'adds' : 'does not add'} 'gl-sr-only' class to the label`, () => {
122
128
  const cssClasses = wrapper.find('[data-testid="toggle-label"]').classes();
123
-
124
129
  return hasGlSrOnlyClass
125
130
  ? expect(cssClasses).toContain('gl-sr-only')
126
131
  : expect(cssClasses).not.toContain('gl-sr-only');
@@ -5,6 +5,10 @@ import readme from './toggle.md';
5
5
 
6
6
  const defaultValue = (prop) => GlToggle.props[prop].default;
7
7
 
8
+ const longHelp = `This is a toggle component with a long help message.
9
+ You can notice how the text wraps when the width of the container
10
+ is not enough to fix the entire text.`;
11
+
8
12
  const generateProps = ({
9
13
  value = true,
10
14
  disabled = defaultValue('disabled'),
@@ -43,6 +47,11 @@ const Template = (args, { argTypes }) => ({
43
47
  export const Default = Template.bind({});
44
48
  Default.args = generateProps();
45
49
 
50
+ export const WithLongHelp = Template.bind({});
51
+ WithLongHelp.args = generateProps({
52
+ help: longHelp,
53
+ });
54
+
46
55
  export default {
47
56
  title: 'base/toggle',
48
57
  component: GlToggle,
@@ -118,13 +118,18 @@ export default {
118
118
 
119
119
  <template>
120
120
  <div
121
- class="gl-toggle-wrapper gl-display-flex gl-flex-direction-column gl-mb-0 gl-w-max-content"
122
- :class="{ 'gl-toggle-label-inline': labelPosition === 'left', 'is-disabled': disabled }"
121
+ class="gl-toggle-wrapper gl-display-flex gl-mb-0"
122
+ :class="{
123
+ 'gl-flex-direction-column': labelPosition === 'top' || labelPosition === 'hidden',
124
+ 'gl-toggle-label-inline': labelPosition === 'left',
125
+ 'is-disabled': disabled,
126
+ }"
127
+ data-testid="toggle-wrapper"
123
128
  >
124
129
  <span
125
130
  :id="labelId"
126
131
  :class="{ 'gl-sr-only': labelPosition === 'hidden' }"
127
- class="gl-toggle-label"
132
+ class="gl-toggle-label gl-flex-shrink-0"
128
133
  data-testid="toggle-label"
129
134
  >
130
135
  <!-- @slot The toggle's label. -->
@@ -141,6 +146,7 @@ export default {
141
146
  'is-checked': value,
142
147
  'is-disabled': disabled,
143
148
  }"
149
+ class="gl-flex-shrink-0"
144
150
  type="button"
145
151
  @click.prevent="toggleFeature"
146
152
  >
@@ -16,11 +16,11 @@ export default {
16
16
  required: true,
17
17
  },
18
18
  value: {
19
- type: String,
19
+ type: [String, Number],
20
20
  required: true,
21
21
  },
22
22
  unit: {
23
- type: [String, Number],
23
+ type: String,
24
24
  required: false,
25
25
  default: null,
26
26
  },