Skip to content

Commit

Permalink
- exploring shadcn/ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Apr 2, 2024
1 parent a15f885 commit b747fd3
Show file tree
Hide file tree
Showing 20 changed files with 1,456 additions and 421 deletions.
48 changes: 25 additions & 23 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,31 @@ async function buildCSS( file ) {
readFile( file, 'utf8' ),
] );

const importLists = [
'colors',
'breakpoints',
'variables',
'mixins',
'animations',
'z-index',
]
// Editor and component styles should be excluded from the default CSS vars output.
.concat(
file.includes( 'common.scss' ) ||
! (
file.includes( 'block-library' ) ||
file.includes( 'components' )
)
? [ 'default-custom-properties' ]
: []
)
.map( ( imported ) => `@import "${ imported }";` )
.join( ' ' );

// const importLists = [
// 'colors',
// 'breakpoints',
// 'variables',
// 'mixins',
// 'animations',
// 'z-index',
// ]
// // Editor and component styles should be excluded from the default CSS vars output.
// .concat(
// file.includes( 'common.scss' ) ||
// ! (
// file.includes( 'block-library' ) ||
// file.includes( 'components' )
// )
// ? [ 'default-custom-properties' ]
// : []
// )
// .map( ( imported ) => `@import "${ imported }";` )
// .join( ' ' );
//
const builtSass = await renderSass( {
file,
includePaths: [ path.join( PACKAGES_DIR, 'base-styles' ) ],
data: ''.concat( '@use "sass:math";', importLists, contents ),
data: ''.concat( '@use "sass:math";', contents ),
} );

const result = await postcss(
Expand Down Expand Up @@ -154,7 +154,7 @@ async function buildJS( file ) {
JS_ENVIRONMENTS
) ) {
const destPath = getBuildPath(
file.replace( /\.tsx?$/, '.js' ),
file.replace( /\.(tsx|jsx)?$/, '.js' ),
buildDir
);
const babelOptions = getBabelConfig(
Expand Down Expand Up @@ -187,7 +187,9 @@ async function buildJS( file ) {
*/
const BUILD_TASK_BY_EXTENSION = {
'.scss': buildCSS,
'.css': buildCSS,
'.js': buildJS,
'.jsx': buildJS,
'.ts': buildJS,
'.tsx': buildJS,
};
Expand Down
16 changes: 6 additions & 10 deletions bin/packages/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const PACKAGES_DIR = path
.replace( /\\/g, '/' );

const stylesheetEntryPoints = glob.sync(
path.resolve( PACKAGES_DIR, '*/src/*.scss' )
path.resolve( PACKAGES_DIR, '*/src/*.css' )
);

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ function createStyleEntryTransform() {
objectMode: true,
async transform( file, encoding, callback ) {
// Only stylesheets are subject to this transform.
if ( path.extname( file ) !== '.scss' ) {
if ( path.extname( file ) !== '.css' ) {
this.push( file );
callback();
return;
Expand All @@ -125,7 +125,7 @@ function createStyleEntryTransform() {
packages.add( packageName );
const entries = await glob(
path
.resolve( PACKAGES_DIR, packageName, 'src/*.scss' )
.resolve( PACKAGES_DIR, packageName, 'src/*.css' )
.replace( /\\/g, '/' )
);

Expand Down Expand Up @@ -221,13 +221,9 @@ if ( files.length ) {

stream = glob.stream(
[
`${ PACKAGES_DIR }/*/src/**/*.{js,ts,tsx}`,
`${ PACKAGES_DIR }/*/src/*.scss`,
`${ PACKAGES_DIR }/block-library/src/**/*.js`,
`${ PACKAGES_DIR }/block-library/src/*/style.scss`,
`${ PACKAGES_DIR }/block-library/src/*/theme.scss`,
`${ PACKAGES_DIR }/block-library/src/*/editor.scss`,
`${ PACKAGES_DIR }/block-library/src/*.scss`,
`${ PACKAGES_DIR }/*/src/**/*.{js,jsx,ts,tsx}`,
`${ PACKAGES_DIR }/*/src/**/**/*.{js,jsx,ts,tsx}`,
`${ PACKAGES_DIR }/*/src/*.css`,
],
{
ignore: [
Expand Down
2 changes: 1 addition & 1 deletion bin/packages/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function isSourceFile( filename ) {
.replace( /\\/g, '/' );

return (
/\/src\/.+\.(js|json|scss|ts|tsx)$/.test( relativePath ) &&
/\/src\/.+\.(js|jsx|json|css|scss|ts|tsx)$/.test( relativePath ) &&
! [
/\/(benchmark|__mocks__|__tests__|test|storybook|stories|e2e-test-utils-playwright)\/.+/,
/.\.(spec|test)\.js$/,
Expand Down
17 changes: 17 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": false,
"tailwind": {
"config": "@ui/tailwind.config.js",
"css": "@ui/globals.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@ui/components",
"utils": "@ui/lib/utils"
}
}
4 changes: 3 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@wpgraphql-ide/*": [ "./*", "./packages/*/src" ]
"@wpgraphql-ide/*": [ "./*", "./packages/*/src" ],
"@ui/*": ["./packages/components/src/*"],
"@components/*": ["./packages/components/src/*"]
}
},
"exclude": [
Expand Down
Loading

0 comments on commit b747fd3

Please sign in to comment.