Skip to content

Commit

Permalink
refactor: refactoring after review
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Oct 20, 2023
1 parent 1de83ba commit db966ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
9 changes: 1 addition & 8 deletions bin/paragon-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const buildTokensCommand = require('../lib/build-tokens');
const replaceVariablesCommand = require('../lib/replace-variables');
const buildScssCommand = require('../lib/build-scss');

const HELP_COMMAND = 'help';

const COMMANDS = {
/**
*'command-name': {
Expand Down Expand Up @@ -151,7 +149,7 @@ const COMMANDS = {
],
},
help: {
executor: helpCommand,
executor: (args) => helpCommand(COMMANDS, args),
parameters: [
{
name: 'command',
Expand Down Expand Up @@ -181,11 +179,6 @@ const COMMANDS = {
return;
}

if (command === HELP_COMMAND) {
helpCommand(COMMANDS, commandArgs);
return;
}

try {
await executor.executor(commandArgs);
} catch (error) {
Expand Down
24 changes: 15 additions & 9 deletions lib/build-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const compileAndWriteStyleSheets = ({
postCSS(commonPostCssPlugins)
.process(compiledStyleSheet.css, { from: stylesPath, map: false })
.then((result) => {
postCSSCompilation.succeed(`Success compilation for ${capitalize(name)} stylesheet`);
postCSSCompilation.succeed(`Successfully compiled ${capitalize(name)} theme stylesheet`);
fs.writeFileSync(`${outDir}/${name}.css`, result.css);
postCSS([postCSSMinify()])
.process(result.css, { from: `${name}.css`, map: { inline: false } })
Expand Down Expand Up @@ -137,9 +137,7 @@ const compileAndWriteStyleSheets = ({
fs.writeFileSync(`${outDir}/${paragonThemeOutputFilename}`, `${JSON.stringify(paragonThemeOutput, null, 2)}\n`);
})
.then(() => {
ora().succeed(chalk.underline.bold.green(`Stylesheets for ${capitalize(name)} build successfully!`));
// eslint-disable-next-line no-console
console.log();
ora().succeed(chalk.underline.bold.green(`Successfully built stylesheet for ${capitalize(name)} theme!\n`));
})
.catch((error) => {
ora().fail(chalk.bold(`Failed to build stylesheets for ${capitalize(name)}: ${error.message}`));
Expand All @@ -152,11 +150,19 @@ const compileAndWriteStyleSheets = ({
* @param {Array<string>} commandArgs - Command line arguments for building SCSS stylesheets.
*/
function buildScssCommand(commandArgs) {
const argv = minimist(commandArgs);
const corePath = argv.corePath || path.resolve(process.cwd(), 'styles/scss/core/core.scss');
const themesPath = argv.themesPath || path.resolve(process.cwd(), 'styles/css/themes');
const outDir = argv.outDir || './dist';
const defaultThemeVariants = argv.defaultThemeVariants ? argv.defaultThemeVariants.split(',') : ['light'];
const defaultArgs = {
corePath: path.resolve(process.cwd(), 'styles/scss/core/core.scss'),
themesPath: path.resolve(process.cwd(), 'styles/css/themes'),
outDir: './dist',
defaultThemeVariants: 'light',
};

const {
corePath,
themesPath,
outDir,
defaultThemeVariants,
} = minimist(commandArgs, { default: defaultArgs });

// Core CSS
compileAndWriteStyleSheets({
Expand Down
2 changes: 1 addition & 1 deletion src/ColorPicker/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

.pgn__hex-label {
font-weight: bold;
font-size: $h5-mobile-font-size;
font-size: var(--pgn-typography-font-size-mobile-h5);
padding: .5rem;
margin-bottom: 0 !important;
}
Expand Down

0 comments on commit db966ac

Please sign in to comment.