Skip to content

Commit 6ac4522

Browse files
committed
introduce a background color
1 parent 5a0ccf8 commit 6ac4522

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ export default config;
3333
## Usage
3434

3535
The primary way to use this addon is to define the `cssswitch` parameter in the preview.ts file. In the option you define
36+
3637
`name` the identifier of the CSS (displayed in the dropdown)
38+
3739
`value` the URL of the CSS (must be available on runtime)
38-
`backgroundColor` a background color which will be applied to the story preview when this css is loaded and is also used for the icon in the dropdown
40+
41+
`backgroundColor` a background color which will be applied to the story preview when this css is loaded and is also used for the icon in the dropdown if no `iconColor` given
42+
43+
`iconColor` an optional icon color used for the icon in the dropdown
3944

4045
```js
4146
// preview.ts

src/components/Tool.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const Tool = memo(function MyAddonSelector({ api }: { api: API }) {
8787
...Object.entries(cssMap).map<Link>(([k, value]) => ({
8888
id: k,
8989
title: value.name,
90-
icon: <CircleIcon color={value?.backgroundColor || 'grey'} />,
90+
icon: <CircleIcon color={value?.iconColor || value?.backgroundColor || 'grey'} />,
9191
active: k === cssName,
9292
onClick: () => {
9393
update({ value: k });

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export interface Css {
33
name: string;
44
value: string;
55
backgroundColor: string;
6+
iconColor?: string;
67
}
78

89
export type CssMap = Record<string, Css>;

0 commit comments

Comments
 (0)