-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ld-theme): ld-theme component and theming docs
- Loading branch information
1 parent
1b2b97e
commit 64fc5af
Showing
10 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import '../../components' // type definitions for type checks and intelliSense | ||
import { Component, h, Host, Prop } from '@stencil/core' | ||
|
||
@Component({ | ||
tag: 'ld-theme', | ||
shadow: false, | ||
}) | ||
export class LdTheme { | ||
/** The theme name. */ | ||
@Prop() name: 'ocean' | 'solvent' | 'bubblegum' | 'shake' | 'tea' = 'ocean' | ||
|
||
render() { | ||
return ( | ||
<Host class={`ld-theme-${this.name}`}> | ||
<slot></slot> | ||
</Host> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
eleventyNavigation: | ||
key: Theme | ||
parent: Components | ||
layout: layout.njk | ||
title: Theme | ||
permalink: liquid/components/ld-theme/ | ||
--- | ||
|
||
# Theme | ||
|
||
Liquid comes with multiple themes for theming its UI components. Most of the examples in the documentation have a theme switch built in, which you can use to switch between the available themes. In the following examples this switch is turned off. Instead, the examples show how you can apply a theme yourself. | ||
|
||
## How to apply a theme | ||
|
||
You apply a theme by wrapping whatever needs to be themed in an `ld-theme` component, or an element with a CSS theme class. | ||
|
||
{% example 'html', false, false, false, false %} | ||
<ld-theme name="bubblegum"> | ||
<ld-button>Text</ld-button> | ||
</ld-theme> | ||
|
||
<!-- CSS component --> | ||
|
||
<div class="ld-theme-bubblegum"> | ||
<button class="ld-button">Text</button> | ||
</div> | ||
{% endexample %} | ||
|
||
## Theme inception | ||
|
||
In rare cases you will want to have a theming element wrapped by another theming element. Liquid supports a one level theme inception, which should be sufficiant for most edge cases. You can **not** wrap a theme in a theme in a theme... So, here is an example of a one level theme inception: | ||
|
||
{% example 'html', false, false, false, false %} | ||
<ld-theme name="bubblegum"> | ||
<ld-theme name="tea"> | ||
<ld-button>Text</ld-button> | ||
</ld-theme> | ||
</ld-theme> | ||
|
||
<!-- CSS component --> | ||
|
||
<div class="ld-theme-bubblegum"> | ||
<div class="ld-theme-tea"> | ||
<button class="ld-button">Text</button> | ||
</div> | ||
</div> | ||
{% endexample %} | ||
|
||
|
||
<!-- Auto Generated Below --> | ||
|
||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| -------- | --------- | --------------- | --------------------------------------------------------- | --------- | | ||
| `name` | `name` | The theme name. | `"bubblegum" \| "ocean" \| "shake" \| "solvent" \| "tea"` | `'ocean'` | | ||
|
||
|
||
---------------------------------------------- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { newSpecPage } from '@stencil/core/testing' | ||
import { LdTheme } from '../ld-theme' | ||
|
||
describe('ld-theme', () => { | ||
it('renders default theme', async () => { | ||
const page = await newSpecPage({ | ||
components: [LdTheme], | ||
html: `<ld-theme>yolo</ld-theme>`, | ||
}) | ||
expect(page.root).toEqualHtml( | ||
`<ld-theme class="ld-theme-ocean">yolo</ld-theme>` | ||
) | ||
}) | ||
it('renders explicit theme', async () => { | ||
const page = await newSpecPage({ | ||
components: [LdTheme], | ||
html: `<ld-theme name="tea">yolo</ld-theme>`, | ||
}) | ||
expect(page.root).toEqualHtml( | ||
`<ld-theme class="ld-theme-tea" name="tea">yolo</ld-theme>` | ||
) | ||
}) | ||
}) |