-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make border only use references for included tokens
- Loading branch information
1 parent
f19507b
commit 80c25a5
Showing
5 changed files
with
76 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// const FILTER_WARNINGS = GroupMessages.GROUP.FilteredOutputReferences | ||
|
||
import type {Dictionary, TransformedToken} from 'style-dictionary/types' | ||
import {getReferences} from 'style-dictionary/utils' | ||
|
||
/** | ||
* @typedef {import('../../../types/DesignToken.d.ts').TransformedToken} TransformedToken | ||
* @typedef {import('../../../types/DesignToken.d.ts').Dictionary} Dictionary | ||
* | ||
* @param {TransformedToken} token | ||
* @param {{ dictionary: Dictionary, usesDtcg?: boolean }} dictionary | ||
* @returns | ||
*/ | ||
export function outputReferencesFilterObject( | ||
token: TransformedToken, | ||
{dictionary, usesDtcg}: {dictionary: Dictionary; usesDtcg?: boolean}, | ||
): boolean { | ||
const originalValue = usesDtcg ? token.original.$value : token.original.value | ||
// get refs, pass unfilteredTokens to ensure we find the refs even if they are filtered out | ||
const refs = getReferences(originalValue, dictionary.tokens, { | ||
unfilteredTokens: dictionary.unfilteredTokens, | ||
usesDtcg, | ||
warnImmediately: false, | ||
}) | ||
|
||
return refs.some(ref => { | ||
// check whether every ref can be found in the filtered set of tokens | ||
const foundToken = dictionary.allTokens.find(thisToken => thisToken.name === ref.name) | ||
if (!foundToken) { | ||
// remove the warning about this ref being filtered out, since we now prevent it from outputting it as a ref | ||
// GroupMessages.remove(FILTER_WARNINGS, ref.path.join('.')) | ||
} | ||
|
||
return !!foundToken | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters