@primer/primitives 7.17.0-rc.a85cfb75 → 7.17.0-rc.a96c5b69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
shadowToCss,
|
|
24
24
|
typographyToCss,
|
|
25
25
|
dimensionToRemPxArray,
|
|
26
|
-
floatToPixel,
|
|
27
26
|
} from './transformers'
|
|
28
27
|
import {
|
|
29
28
|
javascriptCommonJs,
|
|
@@ -133,11 +132,6 @@ StyleDictionary.registerTransform({
|
|
|
133
132
|
...colorToHex,
|
|
134
133
|
})
|
|
135
134
|
|
|
136
|
-
StyleDictionary.registerTransform({
|
|
137
|
-
name: 'float/pixel',
|
|
138
|
-
...floatToPixel,
|
|
139
|
-
})
|
|
140
|
-
|
|
141
135
|
StyleDictionary.registerTransform({
|
|
142
136
|
name: 'dimension/rem',
|
|
143
137
|
...dimensionToRem,
|
package/src/filters/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ export {isDeprecated} from './isDeprecated'
|
|
|
7
7
|
export {isFromFile} from './isFromFile'
|
|
8
8
|
export {isFontFamily} from './isFontFamily'
|
|
9
9
|
export {isFontWeight} from './isFontWeight'
|
|
10
|
-
export {isNumber} from './isNumber'
|
|
11
10
|
export {isShadow} from './isShadow'
|
|
12
11
|
export {isSource} from './isSource'
|
|
13
12
|
export {isTypography} from './isTypography'
|
|
@@ -4,7 +4,6 @@ export {colorToHexAlpha} from './colorToHexAlpha'
|
|
|
4
4
|
export {colorToHexMix} from './colorToHexMix'
|
|
5
5
|
export {colorToRgbAlpha} from './colorToRgbAlpha'
|
|
6
6
|
export {colorToRgbaFloat} from './colorToRgbaFloat'
|
|
7
|
-
export {floatToPixel} from './floatToPixel'
|
|
8
7
|
export {dimensionToRem} from './dimensionToRem'
|
|
9
8
|
export {dimensionToRemPxArray} from './dimensionToRemPxArray'
|
|
10
9
|
export {dimensionToPixelUnitless} from './dimensionToPixelUnitless'
|
package/src/filters/isNumber.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @description Checks if token type is a number
|
|
5
|
-
* @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
6
|
-
* @returns boolean
|
|
7
|
-
*/
|
|
8
|
-
export const isNumber = (token: StyleDictionary.TransformedToken): boolean => token.$type === 'number'
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import {isNumber} from '../filters'
|
|
3
|
-
/**
|
|
4
|
-
* takes a value and returns it if its a px string if it is a float and the token has a fontSize value in extensions['org.primer.data']
|
|
5
|
-
* @param value
|
|
6
|
-
* @returns string
|
|
7
|
-
*/
|
|
8
|
-
export const convertFloatToPixel = (token: StyleDictionary.TransformedToken) => {
|
|
9
|
-
// short circut if value is not a number
|
|
10
|
-
if (
|
|
11
|
-
typeof token.value !== 'number' ||
|
|
12
|
-
!token.$extensions?.['org.primer.data']?.fontSize ||
|
|
13
|
-
typeof token.$extensions?.['org.primer.data']?.fontSize !== 'number'
|
|
14
|
-
) {
|
|
15
|
-
return token.value
|
|
16
|
-
}
|
|
17
|
-
// convert value
|
|
18
|
-
const convertedValue = token.$extensions?.['org.primer.data']?.fontSize * token.value
|
|
19
|
-
// return converted value
|
|
20
|
-
return convertedValue === 0 ? 0 : `${convertedValue}px`
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @description converts a float value to a pixel value based on the provided fontSize on the tokersn extension
|
|
24
|
-
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
25
|
-
* @matcher matches all tokens of $type `isNumber`
|
|
26
|
-
* @transformer returns a pixel string
|
|
27
|
-
*/
|
|
28
|
-
export const floatToPixel: StyleDictionary.Transform = {
|
|
29
|
-
type: `value`,
|
|
30
|
-
transitive: true,
|
|
31
|
-
matcher: isNumber,
|
|
32
|
-
transformer: (token: StyleDictionary.TransformedToken): string => convertFloatToPixel(token),
|
|
33
|
-
}
|