@@ -7,6 +7,7 @@ import { roundRgba } from './convertColor'
7
7
import { changeNotation } from './changeNotation'
8
8
import { getVariableTypeByValue } from './getVariableTypeByValue'
9
9
import roundWithDecimals from './roundWithDecimals'
10
+ import { Settings } from '@typings/settings'
10
11
11
12
const extractVariable = ( variable , value ) => {
12
13
let category : tokenCategoryType = 'color'
@@ -92,11 +93,13 @@ const processAliasModes = (variables) => {
92
93
} , [ ] )
93
94
}
94
95
95
- export const getVariables = ( figma : PluginAPI , modeReference : boolean ) => {
96
+ export const getVariables = ( figma : PluginAPI , settings : Settings ) => {
97
+ const excludedCollectionIds = figma . variables . getLocalVariableCollections ( ) . filter ( collection => ! [ '.' , '_' , ...settings . exclusionPrefix . split ( ',' ) ] . includes ( collection . name . charAt ( 0 ) ) ) . map ( collection => collection . id ) ;
96
98
// get collections
97
99
const collections = Object . fromEntries ( figma . variables . getLocalVariableCollections ( ) . map ( ( collection ) => [ collection . id , collection ] ) )
100
+
98
101
// get variables
99
- const variables = figma . variables . getLocalVariables ( ) . map ( ( variable ) => {
102
+ const variables = figma . variables . getLocalVariables ( ) . filter ( variable => excludedCollectionIds . includes ( variable . variableCollectionId ) ) . map ( ( variable ) => {
100
103
// get collection name and modes
101
104
const { variableCollectionId } = variable
102
105
const { name : collection , modes } = collections [ variableCollectionId ]
@@ -105,11 +108,11 @@ export const getVariables = (figma: PluginAPI, modeReference: boolean) => {
105
108
return {
106
109
...extractVariable ( variable , value ) ,
107
110
// name is contstructed from collection, mode and variable name
108
- name : modeReference ? `${ collection } /${ modes . find ( ( { modeId } ) => modeId === id ) . name } /${ variable . name } ` : `${ collection } /${ variable . name } ` ,
111
+ name : settings . modeReference ? `${ collection } /${ modes . find ( ( { modeId } ) => modeId === id ) . name } /${ variable . name } ` : `${ collection } /${ variable . name } ` ,
109
112
// add mnetadata to extensions
110
113
extensions : {
111
114
[ config . key . extensionPluginData ] : {
112
- mode : modeReference ? modes . find ( ( { modeId } ) => modeId === id ) . name : undefined ,
115
+ mode : settings . modeReference ? modes . find ( ( { modeId } ) => modeId === id ) . name : undefined ,
113
116
collection : collection ,
114
117
scopes : variable . scopes ,
115
118
[ config . key . extensionVariableStyleId ] : variable . id ,
@@ -120,8 +123,5 @@ export const getVariables = (figma: PluginAPI, modeReference: boolean) => {
120
123
} )
121
124
} )
122
125
123
- return modeReference ? processAliasModes ( variables . flat ( ) ) : variables . flat ( ) ;
124
- }
125
-
126
-
127
-
126
+ return settings . modeReference ? processAliasModes ( variables . flat ( ) ) : variables . flat ( ) ;
127
+ }
0 commit comments