-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
8b3abb9
commit fec86bb
Showing
10 changed files
with
703 additions
and
133 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
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
import {defineConfig, ModuleFormat, OutputOptions, RollupOptions} from 'rollup'; | ||
import {dependencies, peerDependencies} from './package.json'; | ||
import withSolid from './tools/with-solid'; | ||
|
||
const externals = [ | ||
...Object.keys(peerDependencies), | ||
...Object.keys(dependencies), | ||
'solid-js/web', | ||
'solid-js/store', | ||
'@vanilla-extract/recipes/createRuntimeFn', | ||
]; | ||
|
||
function buildOutput(format: ModuleFormat): OutputOptions { | ||
return { | ||
preserveModules: true, | ||
preserveModulesRoot: 'src', | ||
assetFileNames({name}) { | ||
return name!.replace(/^src\//, ''); | ||
}, | ||
exports: 'named', | ||
dir: `./dist/${format}`, | ||
format: format, | ||
}; | ||
} | ||
|
||
const solidConfig = withSolid({ | ||
input: { | ||
index: 'src/index.tsx', | ||
'lightTheme.css': './src/lib/themes/light-theme.css.ts', | ||
'darkTheme.css': './src/lib/themes/dark-theme.css.ts', | ||
}, | ||
targets: ['esm', 'cjs'], | ||
external: externals, | ||
output: [buildOutput('esm'), buildOutput('cjs')], | ||
}); | ||
|
||
export default defineConfig(solidConfig as RollupOptions); |
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
30 changes: 30 additions & 0 deletions
30
packages/ui/src/lib/primitives/ColorPicker/ColorPickerPresetItem.tsx
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 @@ | ||
import {assignInlineVars} from '@vanilla-extract/dynamic'; | ||
import {PropsWithChildren} from 'solid-js'; | ||
import {backgroundColorVar} from '../../theme'; | ||
import {Box} from '../Box'; | ||
import * as styles from './ColorPicker.css'; | ||
import {ColorPickerColorItemProps} from './ColorPicker.css'; | ||
|
||
type ColorPickerPresetItemProps = { | ||
title: string; | ||
color: string; | ||
onClick: (color: string) => void; | ||
active: boolean; | ||
} & ColorPickerColorItemProps; | ||
|
||
export function ColorPickerPresetItem( | ||
props: PropsWithChildren<ColorPickerPresetItemProps>, | ||
) { | ||
return ( | ||
<Box | ||
class={styles.colorItem({ | ||
active: props.active, | ||
})} | ||
title={props.title} | ||
style={assignInlineVars({ | ||
[backgroundColorVar]: props.color, | ||
})} | ||
onClick={() => props.onClick(props.color)} | ||
/> | ||
); | ||
} |
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,56 @@ | ||
import chalk from 'chalk'; | ||
import {isAbsolute, resolve} from 'path'; | ||
import ms from 'pretty-ms'; | ||
import {OutputOptions, rollup, RollupOptions} from 'rollup'; | ||
import rollupConfig from '../rollup.config'; | ||
|
||
const log = chalk; | ||
const outputOptions = rollupConfig.output as OutputOptions[]; | ||
|
||
build(); | ||
|
||
function relativeId(id: string): string { | ||
if (!isAbsolute(id)) return id; | ||
return resolve(id); | ||
} | ||
|
||
async function build() { | ||
let bundle; | ||
const start = Date.now(); | ||
let buildFailed = false; | ||
try { | ||
// create a bundle | ||
const files = outputOptions.map(t => relativeId(t.file! || t.dir!)); | ||
let inputFiles: string | undefined; | ||
if (typeof rollupConfig.input === 'string') { | ||
inputFiles = rollupConfig.input; | ||
} else if (rollupConfig.input instanceof Array) { | ||
inputFiles = rollupConfig.input.join(', '); | ||
} else if ( | ||
typeof rollupConfig.input === 'object' && | ||
rollupConfig.input !== null | ||
) { | ||
inputFiles = Object.values(rollupConfig.input).join(', '); | ||
} | ||
console.log( | ||
log.cyan(`\n${log.bold(inputFiles!)} → ${log.bold(files.join(', '))}...`), | ||
); | ||
bundle = await rollup(rollupConfig); | ||
await Promise.all((outputOptions as RollupOptions[]).map(bundle.write)); | ||
console.log( | ||
log.green( | ||
`created ${log.bold(files.join(', '))} in ${chalk.bold( | ||
ms(Date.now() - start), | ||
)}`, | ||
), | ||
); | ||
} catch (error) { | ||
buildFailed = true; | ||
console.error(error); | ||
} | ||
if (bundle) { | ||
// closes the bundle | ||
await bundle.close(); | ||
} | ||
process.exit(buildFailed ? 1 : 0); | ||
} |
Oops, something went wrong.