Skip to content

Commit

Permalink
feat(dark-theme-styles-injector): add prop for selector (#709)
Browse files Browse the repository at this point in the history
* feat(themes): change colors building

* feat(dark-theme-styles-injector): add prop for selector
  • Loading branch information
dmitrsavk committed Jun 22, 2021
1 parent 24a8f08 commit f74cdc7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/build-themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const processPostCss = async (content, cssFile) =>
fs.writeFileSync(`../css/colors/${path.basename(file)}`, css);
fs.writeFileSync(
`../css/colors/${path.basename(file).replace(/\.css$/, '.js')}`,
`module.exports = \`${css}\``,
`module.exports = \`${vars}\``,
);
});

Expand Down
21 changes: 19 additions & 2 deletions packages/dark-theme-styles-injector/src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,35 @@ const colorsMap = {
};

export type DarkThemeStylesInjectorProps = {
/**
* Какие цвета необходимо инвертировать
*/
colors: 'indigo' | 'bluetint';

/**
* Дополнительные стили для инвертированного режима
*/
styles?: string;

/**
* Селектор, в котором будут переопределяться переменные
*/
selector?: string;
};

export const DarkThemeStylesInjector: FC<DarkThemeStylesInjectorProps> = ({
colors,
styles = '',
selector = ':root',
}) => {
return (
<style>
{colorsMap[colors]}
{styles}
{`
${selector} {
${colorsMap[colors]}
${styles}
}
`}
</style>
);
};

0 comments on commit f74cdc7

Please sign in to comment.