import extractorInterface from '@typings/extractorInterface' ; import { borderPropertyInterface } from '@typings/propertyObject' ; import { StrokeCap , StrokeAlign , PropertyType } from '@typings/valueTypes' ; import { customTokenNode } from '@typings/tokenNodeTypes' ; import roundWithDecimals from '../utilities/roundWithDecimals' ; import { tokenTypes } from '@config/tokenTypes' ; import { filterByPrefix } from './extractUtilities' ; import { tokenCategoryType } from '@typings/tokenCategory' ; import { tokenExportKeyType } from '@typings/tokenExportKey' ; import config from '@config/config' ; const strokeJoins = { MITER : 'miter' , BEVEL : 'bevel' , ROUND : 'round' } ; const strokeAligns = { CENTER : 'center' , INSIDE : 'inside' , OUTSIDE : 'outside' } ; const extractBorders = ( tokenNodes , prefixArray ) : borderPropertyInterface [ ] => { return tokenNodes . filter ( filterByPrefix ( prefixArray ) ) . filter ( node => node . strokes . length > 0 ) . map ( node => ( { name : node . name , category : 'border' as tokenCategoryType , exportKey : tokenTypes . border . key as tokenExportKeyType , description : node . description || null , values : { strokeAlign : { value : strokeAligns [ node . strokeAlign ] as StrokeAlign , type : 'string' as PropertyType } , dashPattern : { value : [ ... node . dashPattern ] , type : 'string' as PropertyType } , strokeCap : { value : ( ( typeof node . strokeCap === 'string' ) ? node . strokeCap . toLowerCase ( ) : 'mixed' ) as StrokeCap , type : 'string' as PropertyType } , strokeJoin : { value : strokeJoins [ node . strokeJoin ] , type : 'string' as PropertyType } , strokeMiterLimit : { value : roundWithDecimals ( node . strokeMiterLimit ) , unit : 'degree' , type : 'number' as PropertyType } , strokeWeight : { value : node . strokeWeight , unit : 'pixel' , type : 'number' as PropertyType } , stroke : { value : node . strokes [ 0 ] , type : 'color' as PropertyType } } , extensions : { [ config . key . extensionPluginData ] : { exportKey : tokenTypes . border . key as tokenExportKeyType } } } ) ) ; } ; export default extractBorders ;