Skip to content

Commit 4b0ffb2

Browse files
committed
fix(styles): fixed wrong BEM syntax on button and color classes
fix ZDS-268 fix ZDS-268
1 parent 1ec9421 commit 4b0ffb2

File tree

3 files changed

+51
-40
lines changed

3 files changed

+51
-40
lines changed

src/elements/button/_button.scss

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
height: $height;
1717
padding: 0 1.125rem;
1818

19-
&.#{$prefix}button--primary {
20-
$id: 'button--primary';
19+
&.#{$prefix}button-primary {
20+
$id: 'button-primary';
2121

2222
color: map-get($theme-color-map, $id);
2323

@@ -26,22 +26,22 @@
2626

2727
&:hover,
2828
&:focus,
29-
&.#{$prefix}button--primary__hover {
29+
&.#{$prefix}button-primary--hover {
3030
background-color: lighten($bg-color, 10%);
3131
}
3232

3333
&:disabled,
34-
&.#{$prefix}button--primary__disabled {
35-
color: map-get($theme-color-map, '#{$id}__disabled');
34+
&.#{$prefix}button-primary--disabled {
35+
color: map-get($theme-color-map, '#{$id}--disabled');
3636
background-color: map-get(
3737
$theme-background-color-map,
38-
'#{$id}__disabled'
38+
'#{$id}--disabled'
3939
);
4040
}
4141
}
4242

43-
&.#{$prefix}button--secondary {
44-
$id: 'button--secondary';
43+
&.#{$prefix}button-secondary {
44+
$id: 'button-secondary';
4545

4646
color: map-get($theme-color-map, $id);
4747

@@ -52,26 +52,26 @@
5252

5353
&:hover,
5454
&:focus,
55-
&.#{$prefix}button--secondary__hover {
56-
color: map-get($theme-color-map, '#{$id}__hover');
57-
background-color: map-get($theme-background-color-map, '#{$id}__hover');
58-
border-color: map-get($theme-background-color-map, '#{$id}__hover');
55+
&.#{$prefix}button-secondary--hover {
56+
color: map-get($theme-color-map, '#{$id}--hover');
57+
background-color: map-get($theme-background-color-map, '#{$id}--hover');
58+
border-color: map-get($theme-background-color-map, '#{$id}--hover');
5959
}
6060

6161
&:disabled,
62-
&.#{$prefix}button--secondary__disabled {
63-
color: map-get($theme-color-map, '#{$id}__disabled');
62+
&.#{$prefix}button-secondary--disabled {
63+
color: map-get($theme-color-map, '#{$id}--disabled');
6464
background-color: map-get(
6565
$theme-background-color-map,
66-
'#{$id}__disabled'
66+
'#{$id}--disabled'
6767
);
68-
border-color: map-get($theme-border-color-map, '#{$id}__disabled');
68+
border-color: map-get($theme-border-color-map, '#{$id}--disabled');
6969
cursor: not-allowed;
7070
}
7171
}
7272
}
7373

74-
.#{$prefix}button__full {
74+
.#{$prefix}button--full {
7575
display: block;
7676
width: 100%;
7777
}

src/elements/button/buttonData.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ const buttonData = {
55
name: 'primary',
66
js: `<button type="button" class="${helpers.classPrefix}button ${
77
helpers.classPrefix
8-
}button--primary" ${
8+
}button-primary" ${
99
helpers.htmlDataVarType
1010
}="button">Primary Button</button>`,
1111
react: false,
1212
angular: false,
1313
vue: false
1414
},
15-
primary__disabled: {
16-
name: 'primary__disabled',
15+
primary_disabled: {
16+
name: 'primary_disabled',
1717
js: `<button type="button" class="${helpers.classPrefix}button ${
1818
helpers.classPrefix
19-
}button--primary ${helpers.classPrefix}button--primary__disabled" ${
19+
}button-primary ${helpers.classPrefix}button-primary--disabled" ${
2020
helpers.htmlDataVarType
2121
}="button">Primary Button</button>`,
2222
react: false,
@@ -27,23 +27,34 @@ const buttonData = {
2727
name: 'secondary',
2828
js: `<a type="button" class="${helpers.classPrefix}button ${
2929
helpers.classPrefix
30-
}button--secondary" ${
30+
}button-secondary" ${
3131
helpers.htmlDataVarType
3232
}="button">Secondary Button</a>`,
3333
react: false,
3434
angular: false,
3535
vue: false
3636
},
37-
secondary__disabled: {
38-
name: 'secondary__disabled',
37+
secondary_disabled: {
38+
name: 'secondary_disabled',
3939
js: `<a type="button" class="${helpers.classPrefix}button ${
4040
helpers.classPrefix
41-
}button--secondary ${helpers.classPrefix}button--secondary__disabled" ${
41+
}button-secondary ${helpers.classPrefix}button-secondary--disabled" ${
4242
helpers.htmlDataVarType
4343
}="button">Secondary Button</a>`,
4444
react: false,
4545
angular: false,
4646
vue: false
47+
},
48+
full: {
49+
name: 'full',
50+
js: `<button type="button" class="${helpers.classPrefix}button ${
51+
helpers.classPrefix
52+
}button-primary ${helpers.classPrefix}button--full" ${
53+
helpers.htmlDataVarType
54+
}="button">Primary Button</button>`,
55+
react: false,
56+
angular: false,
57+
vue: false
4758
}
4859
};
4960

src/guidelines/_colors.scss

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,38 @@ $additional-gray-1: #c1c7c9;
2424

2525
/* FIXME: don 't use additional color in production */
2626
$theme-color-map: (
27-
button--primary: map-get($colormap-base, white),
28-
button--primary__disabled: $additional-gray-1,
29-
button--secondary: map-get($colormap-base, grey-dark),
30-
button--secondary__hover: map-get($colormap-base, white),
31-
button--secondary__disabled: $additional-gray-1
27+
button-primary: map-get($colormap-base, white),
28+
button-primary--disabled: $additional-gray-1,
29+
button-secondary: map-get($colormap-base, grey-dark),
30+
button-secondary--hover: map-get($colormap-base, white),
31+
button-secondary--disabled: $additional-gray-1
3232
);
3333

3434
$theme-background-color-map: (
35-
button--primary: map-get($colormap-base, indigo-blue),
36-
button--primary__disabled: map-get($colormap-base, gray-lighter),
37-
button--secondary: map-get($colormap-base, white),
38-
button--secondary__hover: map-get($colormap-base, indigo-blue),
39-
button--secondary__disabled: map-get($colormap-base, white)
35+
button-primary: map-get($colormap-base, indigo-blue),
36+
button-primary--disabled: map-get($colormap-base, gray-lighter),
37+
button-secondary: map-get($colormap-base, white),
38+
button-secondary--hover: map-get($colormap-base, indigo-blue),
39+
button-secondary--disabled: map-get($colormap-base, white)
4040
);
4141

4242
$theme-border-color-map: (
43-
button--secondary: map-get($colormap-base, indigo-blue),
44-
button--secondary__disabled: map-get($colormap-base, gray-lighter)
43+
button-secondary: map-get($colormap-base, indigo-blue),
44+
button-secondary--disabled: map-get($colormap-base, gray-lighter)
4545
);
4646

4747
//use darken 15% on hover colors
4848
$hover-example: darken(map-get($colormap-base, indigo-blue), 15%);
4949

5050
// create dummy color classes
5151
@each $name, $value in $colormap-base {
52-
.#{$prefix}color__#{$name} {
52+
.#{$prefix}color--#{$name} {
5353
color: $value;
5454
}
55-
.#{$prefix}background-color__#{$name} {
55+
.#{$prefix}background-color--#{$name} {
5656
background-color: $value;
5757
}
58-
.#{$prefix}border-color__#{$name} {
58+
.#{$prefix}border-color--#{$name} {
5959
border-color: $value;
6060
}
6161
}

0 commit comments

Comments
 (0)