-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c19b306
commit 01f457d
Showing
43 changed files
with
3,832 additions
and
2,620 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,14 @@ | ||
{ | ||
"extends": ["prettier"], | ||
"plugins": ["prettier", "@typescript-eslint"], | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": [ | ||
"warn", | ||
{ | ||
"argsIgnorePattern": "^_", | ||
"varsIgnorePattern": "^_", | ||
"caughtErrorsIgnorePattern": "^_" | ||
} | ||
] | ||
} | ||
} |
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,3 +1,5 @@ | ||
{ | ||
"semi": false, | ||
"tabWidth": 4, | ||
"useTabs": true | ||
} |
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,51 +1,51 @@ | ||
import { borderRadius } from "./rules/border-radius"; | ||
import { config } from "./root.config"; | ||
import { cursor } from "./rules/cursor"; | ||
import { display } from "./rules/display"; | ||
import { easings } from "./root.easings"; | ||
import { flex } from "./rules/flex"; | ||
import { generateOutput } from "./generators"; | ||
import { grid } from "./rules/grid"; | ||
import { height } from "./rules/height"; | ||
import { list } from "./rules/list"; | ||
import { margin } from "./rules/margin"; | ||
import { opacity } from "./rules/opacity"; | ||
import { overflow } from "./rules/overflow"; | ||
import { padding } from "./rules/padding"; | ||
import { position } from "./rules/position"; | ||
import { reset } from "./root.reset"; | ||
import { type } from "./rules/type"; | ||
import { width } from "./rules/width"; | ||
import { writeFile } from "./utils"; | ||
import type { FractureFiles } from "./types/meta"; | ||
import { borderRadius } from "./rules/border-radius" | ||
import { config } from "./root.config" | ||
import { cursor } from "./rules/cursor" | ||
import { display } from "./rules/display" | ||
import { easings } from "./root.easings" | ||
import { flex } from "./rules/flex" | ||
import { generateOutput } from "./generators" | ||
import { grid } from "./rules/grid" | ||
import { height } from "./rules/height" | ||
import { list } from "./rules/list" | ||
import { margin } from "./rules/margin" | ||
import { opacity } from "./rules/opacity" | ||
import { overflow } from "./rules/overflow" | ||
import { padding } from "./rules/padding" | ||
import { position } from "./rules/position" | ||
import { reset } from "./root.reset" | ||
import { type } from "./rules/type" | ||
import { width } from "./rules/width" | ||
import { writeFile } from "./utils" | ||
import type { FractureFiles } from "./types/meta" | ||
|
||
export const fractureFiles: FractureFiles = { | ||
borderRadius, | ||
cursor, | ||
display, | ||
flex, | ||
grid, | ||
height, | ||
list, | ||
margin, | ||
opacity, | ||
overflow, | ||
padding, | ||
position, | ||
type, | ||
width, | ||
}; | ||
borderRadius, | ||
cursor, | ||
display, | ||
flex, | ||
grid, | ||
height, | ||
list, | ||
margin, | ||
opacity, | ||
overflow, | ||
padding, | ||
position, | ||
type, | ||
width, | ||
} | ||
|
||
// generates standalone versions, each containing only their specific parts. | ||
// TODO this can be just a copy. | ||
writeFile('dist/fractures.reset.css', reset); | ||
writeFile('dist/fractures.config.css', config); | ||
writeFile('dist/fractures.easings.css', easings); | ||
writeFile("dist/fractures.reset.css", reset) | ||
writeFile("dist/fractures.config.css", config) | ||
writeFile("dist/fractures.easings.css", easings) | ||
|
||
// generates the default bundle. | ||
generateOutput(fractureFiles, config + reset, "dist/fractures.min.css"); | ||
generateOutput(fractureFiles, config + reset, "dist/fractures.min.css") | ||
|
||
// generates set of files, eg.: `@heliosgraphics/fractures/dist/set/flex.css` | ||
Object.entries(fractureFiles).forEach(rules => { | ||
generateOutput(rules[1], '', `dist/set/${rules[0]}.css`); | ||
Object.entries(fractureFiles).forEach((rules) => { | ||
generateOutput(rules[1], "", `dist/set/${rules[0]}.css`) | ||
}) |
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,58 +1,61 @@ | ||
import type { FractureRuleType, FractureFiles } from "./types/meta"; | ||
import { writeFile } from "./utils"; | ||
import type { FractureRuleType, FractureFiles } from "./types/meta" | ||
import { writeFile } from "./utils" | ||
|
||
// Generates all the rules for the declarations | ||
export const _generateRule = ( | ||
fractureRule: FractureRuleType | ||
): string => { | ||
const declarations: Array<[string, string]> = Object.entries(fractureRule.declarations || {}) | ||
const variables: Array<[string, string]> = Object.entries(fractureRule.variables || {}) | ||
const hasMultipleDeclarations: boolean = (declarations.length + variables.length) > 1 | ||
|
||
const declarationSpace: string = hasMultipleDeclarations ? "\n" : "" | ||
const declarationOutput: string = declarations | ||
.map((prop) => { | ||
const property: string = prop[0].replace( | ||
/[A-Z]/g, | ||
(letter) => `-${letter.toLowerCase()}` | ||
); | ||
|
||
return `${property}: ${prop[1]};` | ||
}) | ||
.join(declarationSpace) | ||
|
||
const variablesOutput = variables.map(variable => `${variable[0]}: ${variable[1]};`) | ||
const rule: string = `${fractureRule.selector} {${declarationSpace}${variablesOutput}${declarationSpace}${declarationOutput}${declarationSpace}}`; | ||
const selector: string = `.${rule}\n` | ||
|
||
return selector; | ||
}; | ||
|
||
export const _generateRules = ( | ||
rules: Array<FractureRuleType> | ||
): string => { | ||
let css: string = ""; | ||
|
||
rules.forEach((rule: FractureRuleType) => { | ||
css += _generateRule(rule); | ||
}); | ||
|
||
return css; | ||
}; | ||
export const _generateRule = (fractureRule: FractureRuleType): string => { | ||
const declarations: Array<[string, string]> = Object.entries( | ||
fractureRule.declarations || {}, | ||
) | ||
const variables: Array<[string, string]> = Object.entries( | ||
fractureRule.variables || {}, | ||
) | ||
const hasMultipleDeclarations: boolean = | ||
declarations.length + variables.length > 1 | ||
|
||
const declarationSpace: string = hasMultipleDeclarations ? "\n" : "" | ||
const declarationOutput: string = declarations | ||
.map((prop) => { | ||
const property: string = prop[0].replace( | ||
/[A-Z]/g, | ||
(letter) => `-${letter.toLowerCase()}`, | ||
) | ||
|
||
return `${property}: ${prop[1]};` | ||
}) | ||
.join(declarationSpace) | ||
|
||
const variablesOutput = variables.map( | ||
(variable) => `${variable[0]}: ${variable[1]};`, | ||
) | ||
const rule: string = `${fractureRule.selector} {${declarationSpace}${variablesOutput}${declarationSpace}${declarationOutput}${declarationSpace}}` | ||
const selector: string = `.${rule}\n` | ||
|
||
return selector | ||
} | ||
|
||
export const _generateRules = (rules: Array<FractureRuleType>): string => { | ||
let css: string = "" | ||
|
||
rules.forEach((rule: FractureRuleType) => { | ||
css += _generateRule(rule) | ||
}) | ||
|
||
return css | ||
} | ||
|
||
// Generates a new fractures file | ||
export const generateOutput = ( | ||
files: FractureFiles, | ||
init: string, | ||
folder: string | ||
files: FractureFiles, | ||
init: string, | ||
folder: string, | ||
) => { | ||
const rules = Object.values(files).flatMap(x => x); | ||
const css: string = ` | ||
const rules = Object.values(files).flatMap((x) => x) | ||
const css: string = ` | ||
${init} | ||
${_generateRules(rules)} | ||
`; | ||
` | ||
|
||
const fractures: string = css.replace(/\s/g, "") | ||
const fractures: string = css.replace(/\s/g, "") | ||
|
||
return writeFile(folder, fractures); | ||
}; | ||
return writeFile(folder, fractures) | ||
} |
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,14 +1,14 @@ | ||
import type { FractureRuleType } from "../types/meta"; | ||
import type { FractureRuleType } from "../types/meta" | ||
|
||
export const borderRadius: Array<FractureRuleType> = [ | ||
{ selector: "radius-1", declarations: { borderRadius: "var(--box-1)" } }, | ||
{ selector: "radius-2", declarations: { borderRadius: "var(--box-2)" } }, | ||
{ selector: "radius-3", declarations: { borderRadius: "var(--box-3)" } }, | ||
{ selector: "radius-4", declarations: { borderRadius: "var(--box-4)" } }, | ||
{ selector: "radius-5", declarations: { borderRadius: "var(--box-5)" } }, | ||
{ selector: "radius-6", declarations: { borderRadius: "var(--box-6)" } }, | ||
{ selector: "radius-7", declarations: { borderRadius: "var(--box-7)" } }, | ||
{ selector: "radius-8", declarations: { borderRadius: "var(--box-8)" } }, | ||
{ selector: "radius-100", declarations: { borderRadius: "100%" } }, | ||
{ selector: "radius-max", declarations: { borderRadius: "9999px" } }, | ||
]; | ||
{ selector: "radius-1", declarations: { borderRadius: "var(--box-1)" } }, | ||
{ selector: "radius-2", declarations: { borderRadius: "var(--box-2)" } }, | ||
{ selector: "radius-3", declarations: { borderRadius: "var(--box-3)" } }, | ||
{ selector: "radius-4", declarations: { borderRadius: "var(--box-4)" } }, | ||
{ selector: "radius-5", declarations: { borderRadius: "var(--box-5)" } }, | ||
{ selector: "radius-6", declarations: { borderRadius: "var(--box-6)" } }, | ||
{ selector: "radius-7", declarations: { borderRadius: "var(--box-7)" } }, | ||
{ selector: "radius-8", declarations: { borderRadius: "var(--box-8)" } }, | ||
{ selector: "radius-100", declarations: { borderRadius: "100%" } }, | ||
{ selector: "radius-max", declarations: { borderRadius: "9999px" } }, | ||
] |
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,17 +1,20 @@ | ||
import type { FractureRuleType } from "../types/meta"; | ||
import type { FractureRuleType } from "../types/meta" | ||
|
||
export const cursor: Array<FractureRuleType> = [ | ||
{ selector: 'no-pointer-events', declarations: { pointerEvents: 'none' } }, | ||
{ selector: 'cursor-context-menu', declarations: { cursor: 'context-menu' } }, | ||
{ selector: 'cursor-crosshair', declarations: { cursor: 'crosshair' } }, | ||
{ selector: 'cursor-grab', declarations: { cursor: 'grab' } }, | ||
{ selector: 'cursor-grabbing', declarations: { cursor: 'grabbing' } }, | ||
{ selector: 'cursor-help', declarations: { cursor: 'help' } }, | ||
{ selector: 'cursor-move', declarations: { cursor: 'move' } }, | ||
{ selector: 'cursor-pointer', declarations: { cursor: 'pointer' } }, | ||
{ selector: 'cursor-progress', declarations: { cursor: 'progress' } }, | ||
{ selector: 'cursor-text', declarations: { cursor: 'text' } }, | ||
{ selector: 'cursor-wait', declarations: { cursor: 'wait' } }, | ||
{ selector: 'cursor-zoom-in', declarations: { cursor: 'zoom-in' } }, | ||
{ selector: 'cursor-zoom-out', declarations: { cursor: 'zoom-out' } }, | ||
]; | ||
{ selector: "no-pointer-events", declarations: { pointerEvents: "none" } }, | ||
{ | ||
selector: "cursor-context-menu", | ||
declarations: { cursor: "context-menu" }, | ||
}, | ||
{ selector: "cursor-crosshair", declarations: { cursor: "crosshair" } }, | ||
{ selector: "cursor-grab", declarations: { cursor: "grab" } }, | ||
{ selector: "cursor-grabbing", declarations: { cursor: "grabbing" } }, | ||
{ selector: "cursor-help", declarations: { cursor: "help" } }, | ||
{ selector: "cursor-move", declarations: { cursor: "move" } }, | ||
{ selector: "cursor-pointer", declarations: { cursor: "pointer" } }, | ||
{ selector: "cursor-progress", declarations: { cursor: "progress" } }, | ||
{ selector: "cursor-text", declarations: { cursor: "text" } }, | ||
{ selector: "cursor-wait", declarations: { cursor: "wait" } }, | ||
{ selector: "cursor-zoom-in", declarations: { cursor: "zoom-in" } }, | ||
{ selector: "cursor-zoom-out", declarations: { cursor: "zoom-out" } }, | ||
] |
Oops, something went wrong.