Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(styled): customizable names of generated css variables (closes #…
- Loading branch information
Showing
18 changed files
with
334 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@linaria/atomic': patch | ||
'@linaria/core': patch | ||
'@linaria/react': patch | ||
'@linaria/tags': patch | ||
'@linaria/testkit': patch | ||
'@linaria/utils': patch | ||
--- | ||
|
||
The new `variableNameSlug` option that allows to customize css variable names (closes #1053). |
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
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
export * from './BaseProcessor'; | ||
export * from './types'; | ||
export { buildSlug } from './utils/buildSlug'; | ||
export { default as isSerializable } from './utils/isSerializable'; | ||
export * from './utils/types'; | ||
export * from './utils/validateParams'; | ||
export { default as BaseProcessor } from './BaseProcessor'; | ||
export { default as TaggedTemplateProcessor } from './TaggedTemplateProcessor'; | ||
export { default as hasMeta } from './utils/hasMeta'; | ||
export { default as toValidCSSIdentifier } from './utils/toValidCSSIdentifier'; |
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,12 @@ | ||
const PLACEHOLDER = /\[(.*?)]/g; | ||
|
||
const isValidArgName = <TArgs>( | ||
key: string | number | symbol, | ||
args: TArgs | ||
): key is keyof TArgs => key in args; | ||
|
||
export function buildSlug<TArgs>(pattern: string, args: TArgs) { | ||
return pattern.replace(PLACEHOLDER, (_, name: string) => | ||
isValidArgName(name, args) ? String(args[name]) : '' | ||
); | ||
} |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import type { TransformOptions } from '@babel/core'; | ||
|
||
import type { ClassNameFn } from '@linaria/utils'; | ||
import type { ClassNameFn, VariableNameFn } from '@linaria/utils'; | ||
|
||
export interface IOptions { | ||
classNameSlug?: string | ClassNameFn; | ||
displayName: boolean; | ||
variableNameSlug?: string | VariableNameFn; | ||
} | ||
|
||
export type IFileContext = Pick<TransformOptions, 'root' | 'filename'>; |
Oops, something went wrong.