Skip to content

Commit

Permalink
docs: Update documentation for theming components and fix demo toggli…
Browse files Browse the repository at this point in the history
…ng theme. #2262
  • Loading branch information
driskull committed Jun 8, 2021
1 parent c959b99 commit d80769a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions conventions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,10 @@ You can then use the `:host()` selector to define your custom colors:
## Light Theme/Dark Theme
All components should allow developers to supply a `theme` property. This theme should _not_ have default value set:
```tsx
@Prop({ reflect: true }) theme: "light" | "dark";
```
In the [global CSS file](https://github.com/Esri/calcite-components/blob/master/src/assets/styles/global.scss), we specify the values of each color for both light and dark theme. This enables theming to be inherited throughout a component tree. Consider this valid example:
```html
<div theme="dark">
<div class="calcite-theme-dark">
<calcite-button>Button text</calcite-button>
<calcite-date-picker></calcite-date-picker>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/demos/_assets/toggles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
} else if (property === "dir") {
document.dir = document.dir === "rtl" ? "ltr" : "rtl";
} else if (property === "theme") {
document.body.setAttribute("theme", document.body.getAttribute("theme") === "dark" ? "light" : "dark");
document.body.classList.toggle("calcite-theme-dark");
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/demos/calcite-inline-editable.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>Calcite Inline Editable</h1>
document.querySelector("#themeSwitch").addEventListener("calciteSwitchChange", () => {
isDarkTheme = !isDarkTheme;
document.querySelectorAll("calcite-accordion").forEach((accordion) => {
accordion.setAttribute("theme", isDarkTheme ? "dark" : "light");
accordion.classList.toggle("calcite-theme-dark", isDarkTheme);
});
});
</script>
Expand Down

0 comments on commit d80769a

Please sign in to comment.