File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 1- export function tw ( classNames : TemplateStringsArray , ...expressions : string [ ] ) : any {
1+ export interface TailwindObject {
2+ source : string
3+ value : ( string | number ) [ ]
4+ }
5+
6+ export function tw ( classNames : TemplateStringsArray , ...expressions : ( string | number ) [ ] ) : TailwindObject {
7+ // const raw
8+ const result = mergeTemplateStrings ( classNames , expressions )
29 return {
310 source : 'tw' ,
4- value : classNames [ 0 ]
11+ value : result
512 ?. replace ( / ( \s | \\ n ) + / g, ' ' )
613 . trim ( )
7- . split ( ' ' )
8- . concat ( expressions ) ,
14+ . split ( ' ' ) ,
15+ }
16+ }
17+
18+ function mergeTemplateStrings ( templateStrings : TemplateStringsArray , values : any [ ] ) {
19+ let result = templateStrings [ 0 ]
20+ for ( let i = 0 ; i < values . length ; i ++ ) {
21+ result += values [ i ] + templateStrings [ i + 1 ]
922 }
23+ return result
1024}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- export type ExpressionType < T = Record < string , any > > = ( ( props : T ) => string | number | ExpressionType | ExpressionType [ ] ) | string
1+ import { TailwindObject } from '../helper'
2+
3+ export type ExpressionType < T = Record < string , any > > =
4+ | ( ( props : T ) => string | number | ExpressionType | ExpressionType [ ] )
5+ | string
6+ | number
7+ | TailwindObject
28
39export function insertExpressions < T > (
410 strings : TemplateStringsArray ,
You can’t perform that action at this time.
0 commit comments