@@ -15,27 +15,20 @@ let cachedCategories: string[] | null = null
1515let cachedTokensByCategory : TokensByCategory | null = null
1616
1717function getCategoryFromTokenName ( tokenName : string ) : string {
18- // CSS variable format: --pf-v6-{category}-...
19- // Split by hyphen and get the category part (index 4 after splitting)
20- const parts = tokenName . split ( '-' )
21- if ( parts . length >= 5 ) {
22- // Handle multi-word categories like 'chart'
23- // Find where the component name starts (after category)
24- // Categories can be: c, t, l, chart, global, hidden, patternfly
25- const category = parts [ 4 ]
26-
27- // Check if this might be a multi-word category
28- // For patterns like: --pf-v6-chart-global-...
29- // we want to check if parts[4] + parts[5] forms a known longer category
30- if ( parts . length >= 6 && parts [ 4 ] === 'chart' && parts [ 5 ] !== '' ) {
31- // For chart tokens, the category is just 'chart'
32- return 'chart'
33- }
34-
35- return category
18+ const nameWithoutPfPrefix = tokenName . replace ( / ^ - - p f - / , '' )
19+ const parts = nameWithoutPfPrefix . split ( / - + / )
20+ if ( / ^ v \d + / . test ( parts [ 0 ] ) ) {
21+ return parts [ 1 ]
3622 }
3723
38- return tokenName
24+ return parts [ 0 ]
25+ // --pf-[t|vX]-
26+ // add test for nonversion token
27+ // strip out leading --pf-
28+ // check if 1st thing is version, strip out version and grab first part after, v6-chart-global
29+ // if not version, put that thing in category
30+ // CSS variable format: --pf-v6-{category}-...
31+ // Split by hyphen and get the category part (index 4 after splitting)
3932}
4033
4134export function getAllTokens ( ) : Token [ ] {
0 commit comments