-
Notifications
You must be signed in to change notification settings - Fork 31
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
Showing
38 changed files
with
1,307 additions
and
63 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 @@ | ||
**/*.js |
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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# fower-plugin-grid | ||
|
||
## 1.78.0 | ||
|
||
### Minor Changes | ||
|
||
- use pnpm | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- @fower/atomic-props@1.78.0 | ||
- @fower/core@1.78.0 | ||
- @fower/utils@1.78.0 | ||
|
||
## 1.77.0 | ||
|
||
### Minor Changes | ||
|
||
- only support react-like lib | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- @fower/atomic-props@1.77.0 | ||
- @fower/core@1.77.0 | ||
- @fower/utils@1.77.0 | ||
|
||
## 1.76.0 | ||
|
||
### Minor Changes | ||
|
||
- improve rounded and shadow | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- @fower/atomic-props@1.76.0 | ||
- @fower/core@1.76.0 | ||
- @fower/utils@1.76.0 | ||
|
||
## 1.75.7 | ||
|
||
### Patch Changes | ||
|
||
- fix auto dark mode | ||
- Updated dependencies | ||
- @fower/atomic-props@1.75.7 | ||
- @fower/core@1.75.7 | ||
- @fower/utils@1.75.7 | ||
|
||
## 1.75.6 | ||
|
||
### Patch Changes | ||
|
||
- improve mappings in auto dark mode | ||
- Updated dependencies | ||
- @fower/atomic-props@1.75.6 | ||
- @fower/core@1.75.6 | ||
- @fower/utils@1.75.6 | ||
|
||
## 1.75.5 | ||
|
||
### Patch Changes | ||
|
||
- improve auto darkmode | ||
- Updated dependencies | ||
- @fower/atomic-props@1.75.5 | ||
- @fower/core@1.75.5 | ||
- @fower/utils@1.75.5 | ||
|
||
## 1.75.4 | ||
|
||
### Patch Changes | ||
|
||
- improve for auto dark mode | ||
- Updated dependencies | ||
- @fower/atomic-props@1.75.4 | ||
- @fower/core@1.75.4 | ||
- @fower/utils@1.75.4 | ||
|
||
## 1.75.3 | ||
|
||
### Patch Changes | ||
|
||
- fix auto dark mode | ||
- Updated dependencies | ||
- @fower/atomic-props@1.75.3 | ||
- @fower/core@1.75.3 | ||
- @fower/utils@1.75.3 | ||
|
||
## 1.75.2 | ||
|
||
### Patch Changes | ||
|
||
- improve auto dark mode | ||
- Updated dependencies | ||
- @fower/atomic-props@1.75.2 | ||
- @fower/core@1.75.2 | ||
- @fower/utils@1.75.2 | ||
|
||
## 1.75.1 | ||
|
||
### Patch Changes | ||
|
||
- fix auto dark mode | ||
- Updated dependencies | ||
- @fower/atomic-props@1.75.1 | ||
- @fower/core@1.75.1 | ||
- @fower/utils@1.75.1 | ||
|
||
## 1.75.0 | ||
|
||
### Minor Changes | ||
|
||
- update colors | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- @fower/atomic-props@1.75.0 | ||
- @fower/core@1.75.0 | ||
- @fower/utils@1.75.0 |
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 @@ | ||
# fower-plugin-gap |
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,98 @@ | ||
const { colors } = require('@fower/colors') | ||
const { presetWeb } = require('@fower/preset-web') | ||
const { kebab, upFirst } = require('@fower/utils') | ||
const { SemicolonPreference } = require('typescript') | ||
const { join } = require('path') | ||
const { Project } = require('ts-morph') | ||
|
||
/** init somethings */ | ||
const project = new Project() | ||
const cwd = process.cwd() | ||
const outPath = join(cwd, 'types', 'index.d.ts') | ||
const sourceFile = project.createSourceFile(outPath, undefined, { | ||
overwrite: true, | ||
}) | ||
|
||
/** add something to sourceFile */ | ||
sourceFile.addImportDeclarations([ | ||
{ | ||
namedImports: ['FowerPlugin', 'ResponsiveValue', 'ResponsiveBoolean'], | ||
moduleSpecifier: '@fower/core', | ||
}, | ||
]) | ||
sourceFile.addStatements(`import * as CSS from 'csstype'`) | ||
sourceFile.addStatements('declare const _default: () => FowerPlugin') | ||
sourceFile.addStatements('export default _default') | ||
|
||
const typingModule = sourceFile.addModule({ | ||
name: `'@fower/atomic-props'`, | ||
}) | ||
|
||
const entries = Object.entries(presetWeb?.theme?.spacings || {}) | ||
|
||
const atoms = [ | ||
{ alias: 'gap', properties: [] }, | ||
{ alias: 'gapX', properties: [] }, | ||
{ alias: 'gapY', properties: [] }, | ||
] | ||
|
||
const props = atoms.reduce((result, { alias, properties }) => { | ||
const items = entries.reduce((r, item, index) => { | ||
const [gapKey, value] = item | ||
const getItem = (isBase = false) => { | ||
let examples = isBase | ||
? [ | ||
`<Box ${alias}-8></Box>`, | ||
`<Box ${alias}-1rem></Box>`, | ||
`<Box ${alias}-4px></Box>`, | ||
`<Box ${alias}={8}></Box>`, | ||
`<Box ${alias}={a + b}></Box>`, | ||
] | ||
: [`<Box ${alias + gapKey}></Box>`] | ||
return { | ||
name: isBase ? `${alias}?` : alias + gapKey + '?', | ||
type: isBase ? 'ResponsiveValue<string|number>' : 'ResponsiveBoolean', | ||
docs: [ | ||
{ | ||
description: [ | ||
`set the gap between child elements to ${isBase ? 'some value' : value}`, | ||
].join('\n'), | ||
tags: [ | ||
{ | ||
tagName: 'example', | ||
text: ['\n', '```tsx', ...examples, '```'], | ||
}, | ||
{ | ||
tagName: 'see', | ||
text: [`https://developer.mozilla.org/en-US/docs/Web/CSS/position`], | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
} | ||
|
||
if (index === 0) r.push(getItem(true)) | ||
|
||
r.push(getItem()) | ||
return r | ||
}, []) | ||
return result.concat(items) | ||
}, []) | ||
|
||
typingModule.addInterface({ | ||
name: 'AtomicProps', | ||
isExported: true, | ||
properties: props, | ||
}) | ||
|
||
/** format types code */ | ||
sourceFile.formatText({ | ||
indentSize: 2, | ||
semicolons: SemicolonPreference.Remove, | ||
}) | ||
|
||
/** save to file */ | ||
sourceFile.save().then(function () { | ||
console.log('typing file created...') | ||
}) |
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,30 @@ | ||
{ | ||
"name": "fower-plugin-gap", | ||
"version": "1.78.0", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"typings": "types/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"types" | ||
], | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"start": "tsdx watch --verbose", | ||
"build:types": "node gen-types.js", | ||
"build": "tsdx build", | ||
"test": "tsdx test --passWithNoTests", | ||
"test:watch": "tsdx test --watch", | ||
"test:cov": "tsdx test --coverage --passWithNoTests", | ||
"lint": "tsdx lint" | ||
}, | ||
"author": "forsigner", | ||
"module": "dist/fower-plugin-gap.esm.js", | ||
"dependencies": { | ||
"@fower/atomic-props": "workspace:*", | ||
"@fower/core": "workspace:*", | ||
"@fower/utils": "workspace:*" | ||
} | ||
} |
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,45 @@ | ||
import { Parser, Atom } from '@fower/core' | ||
import plugin from '.' | ||
|
||
const { isMatch, handleAtom } = plugin() | ||
const parser = {} as Parser | ||
|
||
test('isMatch', () => { | ||
expect(isMatch!('gap')).toEqual(true) | ||
expect(isMatch!('rowGap')).toEqual(true) | ||
expect(isMatch!('columnGap')).toEqual(true) | ||
expect(isMatch!('gridTemplateColumns')).toEqual(true) | ||
}) | ||
|
||
test('rowGap={8}', () => { | ||
const atom = handleAtom!( | ||
new Atom({ | ||
propKey: 'rowGap', | ||
propValue: 8, | ||
}), | ||
parser, | ||
) | ||
expect(atom.style.rowGap).toEqual(8) | ||
}) | ||
|
||
test('columnGap={8}', () => { | ||
const atom = handleAtom!( | ||
new Atom({ | ||
propKey: 'columnGap', | ||
propValue: 8, | ||
}), | ||
parser, | ||
) | ||
expect(atom.style.columnGap).toEqual(8) | ||
}) | ||
|
||
test('gridTemplateColumns={4}', () => { | ||
const atom = handleAtom!( | ||
new Atom({ | ||
propKey: 'gridTemplateColumns', | ||
propValue: 4, | ||
}), | ||
parser, | ||
) | ||
expect(atom.style.gridTemplateColumns).toEqual('repeat(4, minmax(0px, 1fr))') | ||
}) |
Oops, something went wrong.