Skip to content

feat(dark-theme-styles-injector): add prop for selector #709

Merged
merged 2 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
};