Skip to content

Commit 65320c8

Browse files
committed
improve BEM modifier pattern matching to support nested modifiers and add color token variants for badge decoration, button link kind, and split button kind
1 parent 076198c commit 65320c8

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

packages/combinator/src/lib/tokens.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ export function resolveTokenValue (category, value, propValues) {
9797
* Resolves a computed color from CSS classes applied to the measure element.
9898
*
9999
* classPrefix patterns:
100-
* 'class[attr]' — sets attr=value, reads from child element (avatar family)
101-
* 'class--' — applies 'class class--{value}' (BEM modifier)
102-
* 'class' — applies 'class-{value}' (utility class)
100+
* 'class[attr]' — sets attr=value, reads from child element (avatar family)
101+
* 'class--' — applies 'class class--{value}' (BEM modifier)
102+
* 'class--modifier-' — applies 'class class--modifier-{value}' (BEM sub-modifier)
103+
* 'class' — applies 'class-{value}' (utility class)
103104
*
104105
* cssProperty patterns:
105106
* 'color', 'backgroundColor' — standard computed style property
@@ -124,12 +125,12 @@ function resolveColor (classPrefix, cssProperty, value) {
124125
}
125126
child.className = `${bracketMatch[1]}__canvas-inner`;
126127
}
127-
// Component modifier pattern: prefix ends with '--' (e.g., 'd-badge--')
128-
// → class = 'd-badge d-badge--{value}'
129-
} else if (classPrefix.endsWith('--')) {
130-
const base = classPrefix.slice(0, -2);
128+
// BEM modifier pattern: prefix contains '--' (e.g., 'd-badge--', 'd-badge--decorate-')
129+
// → class = 'd-badge d-badge--{value}' or 'd-badge d-badge--decorate-{value}'
130+
} else if (classPrefix.includes('--')) {
131+
const base = classPrefix.slice(0, classPrefix.indexOf('--'));
131132
el.className = `${base} ${classPrefix}${value}`;
132-
// Utility pattern: no '--' suffix (e.g., 'd-fc')
133+
// Utility pattern: no '--' (e.g., 'd-fc')
133134
// → class = 'd-fc-{value}'
134135
} else {
135136
el.className = `${classPrefix}-${value}`;

packages/combinator/src/variants/variants_badge.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default {
55
props: {
66
iconSize: { tokenCategory: 'icon-size' },
77
type: { tokenCategory: 'color:d-badge--:backgroundColor' },
8+
decoration: { tokenCategory: 'color:d-badge--decorate-:--badge-decorative-color' },
89
},
910
},
1011

packages/combinator/src/variants/variants_button.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default {
33
defaults: {
44
props: {
55
kind: { tokenCategory: 'color:d-btn--:color' },
6+
linkKind: { tokenCategory: 'color:d-link--:color' },
67
},
78
},
89

packages/combinator/src/variants/variants_split_button.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33

44
export default {
5+
defaults: {
6+
props: {
7+
kind: { tokenCategory: 'color:d-btn--:color' },
8+
},
9+
},
10+
511
exclusions: [
612
{
713
when: { importance: v => v !== 'clear' },

packages/dialtone-vue/components/button/button.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ export default {
324324
325325
/**
326326
* The color of the button.
327-
* The inverted value is deprecated — use v-dt-mode directive instead.
328327
* @values default, unstyled, muted, critical, positive
329328
*/
330329
kind: {

packages/dialtone-vue/components/split_button/split_button.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export default {
370370
371371
/**
372372
* The color of the button.
373-
* @values default, muted, critical
373+
* @values default, unstyled, muted, critical, positive
374374
*/
375375
kind: {
376376
type: String,

0 commit comments

Comments
 (0)