@lion/ui 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/core/test/SlotMixin.test.js +28 -21
- package/components/drawer/src/LionDrawer.js +217 -0
- package/components/drawer/src/drawerStyle.js +59 -0
- package/components/drawer/test/lion-drawer.test.js +109 -0
- package/components/localize/src/number/parseNumber.js +15 -36
- package/components/localize/test/number/parseNumber.test.js +3 -12
- package/custom-elements.json +743 -0
- package/dist-types/components/drawer/src/LionDrawer.d.ts +67 -0
- package/dist-types/components/drawer/src/LionDrawer.d.ts.map +1 -0
- package/dist-types/components/drawer/src/drawerStyle.d.ts +2 -0
- package/dist-types/components/drawer/src/drawerStyle.d.ts.map +1 -0
- package/dist-types/components/drawer/test/lion-drawer.test.d.ts +3 -0
- package/dist-types/components/drawer/test/lion-drawer.test.d.ts.map +1 -0
- package/dist-types/components/localize/src/number/parseNumber.d.ts.map +1 -1
- package/dist-types/exports/define/lion-drawer.d.ts +2 -0
- package/dist-types/exports/define/lion-drawer.d.ts.map +1 -0
- package/dist-types/exports/drawer.d.ts +2 -0
- package/dist-types/exports/drawer.d.ts.map +1 -0
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/accordion/index.md +3 -0
- package/docs/components/accordion/overview.md +129 -0
- package/docs/components/accordion/reference.md +47 -0
- package/docs/components/accordion/use-cases.md +252 -0
- package/docs/components/button/examples.md +30 -0
- package/docs/components/button/index.md +3 -0
- package/docs/components/button/overview.md +30 -0
- package/docs/components/button/src/icon.svg.js +5 -0
- package/docs/components/button/use-cases.md +106 -0
- package/docs/components/calendar/index.md +3 -0
- package/docs/components/calendar/overview.md +49 -0
- package/docs/components/calendar/use-cases.md +192 -0
- package/docs/components/checkbox-group/index.md +3 -0
- package/docs/components/checkbox-group/overview.md +40 -0
- package/docs/components/checkbox-group/use-cases.md +256 -0
- package/docs/components/collapsible/assets/CustomCollapsible.js +113 -0
- package/docs/components/collapsible/assets/applyDemoCollapsibleStyles.js +37 -0
- package/docs/components/collapsible/examples.md +83 -0
- package/docs/components/collapsible/index.md +3 -0
- package/docs/components/collapsible/overview.md +39 -0
- package/docs/components/collapsible/use-cases.md +79 -0
- package/docs/components/combobox/examples.md +153 -0
- package/docs/components/combobox/index.md +3 -0
- package/docs/components/combobox/overview.md +51 -0
- package/docs/components/combobox/src/LinkMixin.js +60 -0
- package/docs/components/combobox/src/demo-selection-display.js +191 -0
- package/docs/components/combobox/src/gh-combobox/gh-button.js +69 -0
- package/docs/components/combobox/src/gh-combobox/gh-combobox.js +508 -0
- package/docs/components/combobox/src/google-combobox/assets/google-clear-icon.js +9 -0
- package/docs/components/combobox/src/google-combobox/assets/google-search-icon.js +9 -0
- package/docs/components/combobox/src/google-combobox/assets/google-voice-search-icon.js +19 -0
- package/docs/components/combobox/src/google-combobox/assets/googlelogo_color_272x92dp.png +0 -0
- package/docs/components/combobox/src/google-combobox/google-combobox.js +460 -0
- package/docs/components/combobox/src/lazyRender.js +29 -0
- package/docs/components/combobox/src/levenshtein.js +95 -0
- package/docs/components/combobox/src/md-combobox/MdFieldMixin.js +341 -0
- package/docs/components/combobox/src/md-combobox/md-combobox.js +89 -0
- package/docs/components/combobox/src/md-combobox/md-input.js +5 -0
- package/docs/components/combobox/src/md-combobox/style/load-roboto.js +6 -0
- package/docs/components/combobox/src/md-combobox/style/md-ripple.js +81 -0
- package/docs/components/combobox/src/wa-combobox/wa-combobox.js +368 -0
- package/docs/components/combobox/use-cases.md +377 -0
- package/docs/components/dialog/index.md +3 -0
- package/docs/components/dialog/overview.md +63 -0
- package/docs/components/dialog/src/demo-dialog-style.js +3 -0
- package/docs/components/dialog/src/demoStyle.js +39 -0
- package/docs/components/dialog/src/slots-dialog-content.js +32 -0
- package/docs/components/dialog/src/styled-dialog-content.js +38 -0
- package/docs/components/dialog/use-cases.md +154 -0
- package/docs/components/drawer/index.md +3 -0
- package/docs/components/drawer/overview.md +68 -0
- package/docs/components/drawer/src/demoStyle.js +71 -0
- package/docs/components/drawer/use-cases.md +194 -0
- package/docs/components/fieldset/index.md +3 -0
- package/docs/components/fieldset/overview.md +49 -0
- package/docs/components/fieldset/use-cases.md +185 -0
- package/docs/components/form/index.md +3 -0
- package/docs/components/form/overview.md +43 -0
- package/docs/components/form/use-cases.md +72 -0
- package/docs/components/icon/assets/bugs/bug01.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug02.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug05.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug06.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug08.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug12.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug19.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug23.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug24.svg.js +2 -0
- package/docs/components/icon/assets/iconset-bugs.js +11 -0
- package/docs/components/icon/assets/iconset-misc.js +3 -0
- package/docs/components/icon/assets/iconset-space.js +31 -0
- package/docs/components/icon/assets/misc/arrowLeft.svg.js +6 -0
- package/docs/components/icon/assets/space/aliens-spaceship.svg.js +2 -0
- package/docs/components/icon/assets/space/meteor.svg.js +2 -0
- package/docs/components/icon/assets/space/moon-flag.svg.js +2 -0
- package/docs/components/icon/assets/space/moon.svg.js +2 -0
- package/docs/components/icon/assets/space/night.svg.js +2 -0
- package/docs/components/icon/assets/space/orbit.svg.js +2 -0
- package/docs/components/icon/assets/space/planet.svg.js +2 -0
- package/docs/components/icon/assets/space/robot.svg.js +2 -0
- package/docs/components/icon/assets/space/rocket.svg.js +2 -0
- package/docs/components/icon/assets/space/satellite.svg.js +2 -0
- package/docs/components/icon/assets/space/signal.svg.js +2 -0
- package/docs/components/icon/assets/space/space-helmet.svg.js +2 -0
- package/docs/components/icon/assets/space/sun.svg.js +2 -0
- package/docs/components/icon/assets/space/telescope.svg.js +2 -0
- package/docs/components/icon/index.md +3 -0
- package/docs/components/icon/overview.md +40 -0
- package/docs/components/icon/use-cases.md +93 -0
- package/docs/components/index.md +7 -0
- package/docs/components/input/index.md +3 -0
- package/docs/components/input/overview.md +36 -0
- package/docs/components/input/use-cases.md +77 -0
- package/docs/components/input-amount/index.md +3 -0
- package/docs/components/input-amount/overview.md +49 -0
- package/docs/components/input-amount/use-cases.md +122 -0
- package/docs/components/input-date/index.md +3 -0
- package/docs/components/input-date/overview.md +39 -0
- package/docs/components/input-date/use-cases.md +83 -0
- package/docs/components/input-datepicker/index.md +3 -0
- package/docs/components/input-datepicker/overview.md +42 -0
- package/docs/components/input-datepicker/use-cases.md +78 -0
- package/docs/components/input-email/index.md +3 -0
- package/docs/components/input-email/overview.md +32 -0
- package/docs/components/input-email/use-cases.md +48 -0
- package/docs/components/input-iban/index.md +3 -0
- package/docs/components/input-iban/overview.md +37 -0
- package/docs/components/input-iban/use-cases.md +102 -0
- package/docs/components/input-range/index.md +3 -0
- package/docs/components/input-range/overview.md +34 -0
- package/docs/components/input-range/use-cases.md +108 -0
- package/docs/components/input-stepper/index.md +3 -0
- package/docs/components/input-stepper/overview.md +36 -0
- package/docs/components/input-stepper/use-cases.md +41 -0
- package/docs/components/input-tel/index.md +3 -0
- package/docs/components/input-tel/overview.md +62 -0
- package/docs/components/input-tel/src/h-region-code-table.js +109 -0
- package/docs/components/input-tel/use-cases.md +307 -0
- package/docs/components/input-tel-dropdown/examples.md +32 -0
- package/docs/components/input-tel-dropdown/index.md +3 -0
- package/docs/components/input-tel-dropdown/overview.md +38 -0
- package/docs/components/input-tel-dropdown/src/intl-input-tel-dropdown.js +127 -0
- package/docs/components/input-tel-dropdown/use-cases.md +159 -0
- package/docs/components/listbox/index.md +3 -0
- package/docs/components/listbox/overview.md +42 -0
- package/docs/components/listbox/src/listboxData.js +65 -0
- package/docs/components/listbox/use-cases.md +147 -0
- package/docs/components/pagination/index.md +3 -0
- package/docs/components/pagination/overview.md +29 -0
- package/docs/components/pagination/use-cases.md +99 -0
- package/docs/components/progress-indicator/assets/my-determinate-progress-bar.js +30 -0
- package/docs/components/progress-indicator/assets/my-indeterminate-progress-spinner.js +55 -0
- package/docs/components/progress-indicator/examples.md +125 -0
- package/docs/components/progress-indicator/index.md +3 -0
- package/docs/components/progress-indicator/overview.md +36 -0
- package/docs/components/radio-group/index.md +3 -0
- package/docs/components/radio-group/overview.md +46 -0
- package/docs/components/radio-group/use-cases.md +140 -0
- package/docs/components/select/index.md +3 -0
- package/docs/components/select/overview.md +44 -0
- package/docs/components/select/use-cases.md +55 -0
- package/docs/components/select-rich/examples.md +31 -0
- package/docs/components/select-rich/index.md +3 -0
- package/docs/components/select-rich/overview.md +46 -0
- package/docs/components/select-rich/src/flagStyles.js +1250 -0
- package/docs/components/select-rich/src/flags.png +0 -0
- package/docs/components/select-rich/src/flags@2x.png +0 -0
- package/docs/components/select-rich/src/intl-select-rich.js +194 -0
- package/docs/components/select-rich/src/regionMetaList.js +1717 -0
- package/docs/components/select-rich/use-cases.md +370 -0
- package/docs/components/steps/index.md +3 -0
- package/docs/components/steps/overview.md +63 -0
- package/docs/components/steps/use-cases.md +163 -0
- package/docs/components/switch/index.md +3 -0
- package/docs/components/switch/overview.md +75 -0
- package/docs/components/switch/reference.md +39 -0
- package/docs/components/switch/use-cases.md +76 -0
- package/docs/components/tabs/examples.md +23 -0
- package/docs/components/tabs/index.md +3 -0
- package/docs/components/tabs/overview.md +48 -0
- package/docs/components/tabs/src/lea-tab-panel.js +24 -0
- package/docs/components/tabs/src/lea-tab.js +45 -0
- package/docs/components/tabs/src/lea-tabs.js +28 -0
- package/docs/components/tabs/use-cases.md +219 -0
- package/docs/components/textarea/index.md +3 -0
- package/docs/components/textarea/overview.md +35 -0
- package/docs/components/textarea/use-cases.md +95 -0
- package/docs/components/tooltip/examples.md +39 -0
- package/docs/components/tooltip/index.md +3 -0
- package/docs/components/tooltip/overview.md +44 -0
- package/docs/components/tooltip/use-cases.md +208 -0
- package/docs/fundamentals/index.md +19 -0
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/overview.md +233 -0
- package/docs/fundamentals/node-tools/index.md +1 -0
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +68 -0
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +111 -0
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +69 -0
- package/docs/fundamentals/node-tools/providence-analytics/assets/_mermaid.svg.js +1202 -0
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +22 -0
- package/docs/fundamentals/node-tools/providence-analytics/index.md +1 -0
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +192 -0
- package/docs/fundamentals/node-tools/publish-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/publish-docs/overview.md +136 -0
- package/docs/fundamentals/node-tools/remark-extend/index.md +1 -0
- package/docs/fundamentals/node-tools/remark-extend/overview.md +274 -0
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +285 -0
- package/docs/fundamentals/rationales/TypeScript.md +18 -0
- package/docs/fundamentals/rationales/index.md +1 -0
- package/docs/fundamentals/rationales/side-effects.md +203 -0
- package/docs/fundamentals/rationales/versioning.md +35 -0
- package/docs/fundamentals/systems/core/index.md +3 -0
- package/docs/fundamentals/systems/core/overview.md +85 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-1.svg +1 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-2.svg +1 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-3.svg +84 -0
- package/docs/fundamentals/systems/form/assets/h-output.js +155 -0
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +245 -0
- package/docs/fundamentals/systems/form/index.md +3 -0
- package/docs/fundamentals/systems/form/interaction-states.md +177 -0
- package/docs/fundamentals/systems/form/model-value.md +35 -0
- package/docs/fundamentals/systems/form/overview.md +82 -0
- package/docs/fundamentals/systems/form/styling.md +101 -0
- package/docs/fundamentals/systems/form/use-cases.md +156 -0
- package/docs/fundamentals/systems/form/validate.md +929 -0
- package/docs/fundamentals/systems/icon/index.md +3 -0
- package/docs/fundamentals/systems/icon/overview.md +124 -0
- package/docs/fundamentals/systems/index.md +1 -0
- package/docs/fundamentals/systems/localize/assets/all-locales.js +437 -0
- package/docs/fundamentals/systems/localize/assets/en-AU.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en-GB.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en-US.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en.js +4 -0
- package/docs/fundamentals/systems/localize/assets/nl-BE.js +6 -0
- package/docs/fundamentals/systems/localize/assets/nl-NL.js +6 -0
- package/docs/fundamentals/systems/localize/assets/nl.js +4 -0
- package/docs/fundamentals/systems/localize/dates.md +195 -0
- package/docs/fundamentals/systems/localize/index.md +3 -0
- package/docs/fundamentals/systems/localize/numbers.md +217 -0
- package/docs/fundamentals/systems/localize/overview.md +48 -0
- package/docs/fundamentals/systems/localize/rationale.md +62 -0
- package/docs/fundamentals/systems/localize/text.md +125 -0
- package/docs/fundamentals/systems/localize/use-cases.md +319 -0
- package/docs/fundamentals/systems/overlays/assets/applyDemoOverlayStyles.js +22 -0
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-backdrop.js +48 -0
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-system.js +42 -0
- package/docs/fundamentals/systems/overlays/assets/umbrella-form.js +133 -0
- package/docs/fundamentals/systems/overlays/configuration.md +453 -0
- package/docs/fundamentals/systems/overlays/form-integration.md +65 -0
- package/docs/fundamentals/systems/overlays/index.md +3 -0
- package/docs/fundamentals/systems/overlays/overview.md +118 -0
- package/docs/fundamentals/systems/overlays/rationale.md +232 -0
- package/docs/fundamentals/systems/overlays/scope.md +176 -0
- package/docs/fundamentals/systems/overlays/use-cases.md +699 -0
- package/docs/fundamentals/tools/ajax/assets/naga.json +9 -0
- package/docs/fundamentals/tools/ajax/assets/pabu.json +9 -0
- package/docs/fundamentals/tools/ajax/index.md +3 -0
- package/docs/fundamentals/tools/ajax/overview.md +128 -0
- package/docs/fundamentals/tools/ajax/use-cases.md +456 -0
- package/docs/fundamentals/tools/helpers/action-logger.md +165 -0
- package/docs/fundamentals/tools/helpers/index.md +3 -0
- package/docs/fundamentals/tools/helpers/overview.md +30 -0
- package/docs/fundamentals/tools/index.md +1 -0
- package/docs/fundamentals/tools/singleton-manager/index.md +3 -0
- package/docs/fundamentals/tools/singleton-manager/overview.md +304 -0
- package/docs/guides/how-to/create-a-custom-field.md +200 -0
- package/docs/guides/how-to/extend-a-native-input.md +66 -0
- package/docs/guides/how-to/get-started.md +77 -0
- package/docs/guides/how-to/index.md +1 -0
- package/docs/guides/index.md +34 -0
- package/docs/guides/principles/definitions-and-terms.md +41 -0
- package/docs/guides/principles/index.md +26 -0
- package/docs/guides/principles/scoped-elements.md +103 -0
- package/docs/guides/principles/styling.md +32 -0
- package/docs/guides/principles/subclasser-apis.md +28 -0
- package/docs/override.js +15 -0
- package/exports/define/lion-drawer.js +3 -0
- package/exports/drawer.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Switch >> Reference ||30
|
|
2
|
+
|
|
3
|
+
<p class="lion-paragraph--emphasis">Everything you need to re-use the switch.</p>
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
This component fulfils the following requirements:
|
|
8
|
+
|
|
9
|
+
1. The component clearly communicates what is it for.
|
|
10
|
+
2. The component supports helper text.
|
|
11
|
+
3. The component supports smart defaults.
|
|
12
|
+
4. The component supports the following states: on, off, hover (Web only), focused, disabled, pressed and processing
|
|
13
|
+
5. The transformation between ON and OFF states are enhanced by an animation.
|
|
14
|
+
6. Toggling the switch (on <-> off) will execute the underlying action immediately.
|
|
15
|
+
|
|
16
|
+
## Keyboard interactions
|
|
17
|
+
|
|
18
|
+
| <kbd>Key</kbd> | Action |
|
|
19
|
+
| :------------------ | :------------------------------------------------------------------------------------------------ |
|
|
20
|
+
| <kbd>Enter</kbd> | On keyboard focus, pressing <kbd>Enter</kbd> changes the state of the switch to “On” or “Off”. |
|
|
21
|
+
| <kbd>Spacebar</kbd> | On keyboard focus, pressing <kbd>Spacebar</kbd> changes the state of the switch to “On” or “Off”. |
|
|
22
|
+
|
|
23
|
+
## WAI-ARIA roles
|
|
24
|
+
|
|
25
|
+
### Landmarks
|
|
26
|
+
|
|
27
|
+
1. element: "button"<br>
|
|
28
|
+
role: "switch"
|
|
29
|
+
|
|
30
|
+
### Screen reader
|
|
31
|
+
|
|
32
|
+
1. name: “Label”<br>
|
|
33
|
+
role: switch<br>
|
|
34
|
+
state: aria-checked=“true”<br>
|
|
35
|
+
SR: “Label, on, switch"
|
|
36
|
+
2. name: “Label”<br>
|
|
37
|
+
role: switch<br>
|
|
38
|
+
state: aria-checked=“false”<br>
|
|
39
|
+
SR: “Label, off, switch”
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Switch >> Use Cases ||20
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
5
|
+
import { Validator } from '@lion/ui/form-core.js';
|
|
6
|
+
import { LionSwitch } from '@lion/ui/switch.js';
|
|
7
|
+
import '@lion/ui/define/lion-switch.js';
|
|
8
|
+
import '@lion/ui/define-helpers/sb-action-logger.js';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Disabled
|
|
12
|
+
|
|
13
|
+
You can disable switches.
|
|
14
|
+
|
|
15
|
+
```html preview-story
|
|
16
|
+
<lion-switch label="Label" disabled></lion-switch>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Validation
|
|
20
|
+
|
|
21
|
+
An example that illustrates how an info validation feedback can be always displayed.
|
|
22
|
+
|
|
23
|
+
```js preview-story
|
|
24
|
+
class IsTrue extends Validator {
|
|
25
|
+
static get validatorName() {
|
|
26
|
+
return 'IsTrue';
|
|
27
|
+
}
|
|
28
|
+
execute(value) {
|
|
29
|
+
return !value.checked;
|
|
30
|
+
}
|
|
31
|
+
static async getMessage() {
|
|
32
|
+
return "You won't get the latest news!";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class CustomSwitch extends LionSwitch {
|
|
37
|
+
static get validationTypes() {
|
|
38
|
+
return [...super.validationTypes, 'info'];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_showFeedbackConditionFor(type, meta) {
|
|
42
|
+
if (type === 'info') {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return super._showFeedbackConditionFor(type, meta);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
customElements.define('custom-switch', CustomSwitch);
|
|
49
|
+
|
|
50
|
+
export const validation = () => html`
|
|
51
|
+
<custom-switch
|
|
52
|
+
name="newsletterCheck"
|
|
53
|
+
label="Subscribe to newsletter"
|
|
54
|
+
.validators="${[new IsTrue(null, { type: 'info' })]}"
|
|
55
|
+
></custom-switch>
|
|
56
|
+
`;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## With checked-changed handler
|
|
60
|
+
|
|
61
|
+
You can listen for a `checked-changed` event that is fired when the switch is clicked.
|
|
62
|
+
|
|
63
|
+
```js preview-story
|
|
64
|
+
export const handler = ({ shadowRoot }) => {
|
|
65
|
+
return html`
|
|
66
|
+
<lion-switch
|
|
67
|
+
label="Label"
|
|
68
|
+
@checked-changed="${ev => {
|
|
69
|
+
shadowRoot.querySelector('sb-action-logger').log(`Current value: ${ev.target.checked}`);
|
|
70
|
+
}}"
|
|
71
|
+
>
|
|
72
|
+
</lion-switch>
|
|
73
|
+
<sb-action-logger></sb-action-logger>
|
|
74
|
+
`;
|
|
75
|
+
};
|
|
76
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Tabs >> Examples ||30
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { LitElement, html } from '@mdjs/mdjs-preview';
|
|
5
|
+
import './src/lea-tabs.js';
|
|
6
|
+
import './src/lea-tab.js';
|
|
7
|
+
import './src/lea-tab-panel.js';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Lea Tabs
|
|
11
|
+
|
|
12
|
+
Learn how to create the `lea tabs` in our ["introducing lion" blogpost](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/blog/ing-open-sources-lion.md).
|
|
13
|
+
|
|
14
|
+
```js preview-story
|
|
15
|
+
export const main = () => html`
|
|
16
|
+
<lea-tabs>
|
|
17
|
+
<lea-tab slot="tab">Info</lea-tab>
|
|
18
|
+
<lea-tab-panel slot="panel"> Info page with lots of information about us. </lea-tab-panel>
|
|
19
|
+
<lea-tab slot="tab">Work</lea-tab>
|
|
20
|
+
<lea-tab-panel slot="panel"> Work page that showcases our work. </lea-tab-panel>
|
|
21
|
+
</lea-tabs>
|
|
22
|
+
`;
|
|
23
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Tabs >> Overview ||10
|
|
2
|
+
|
|
3
|
+
A web component that allows users to quickly move between a small number of equally important views.
|
|
4
|
+
|
|
5
|
+
```js script
|
|
6
|
+
import { LitElement, html } from '@mdjs/mdjs-preview';
|
|
7
|
+
import '@lion/ui/define/lion-tabs.js';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```js preview-story
|
|
11
|
+
export const main = () => html`
|
|
12
|
+
<lion-tabs>
|
|
13
|
+
<button slot="tab">Info</button>
|
|
14
|
+
<p slot="panel">Info page with lots of information about us.</p>
|
|
15
|
+
<button slot="tab">Work</button>
|
|
16
|
+
<p slot="panel">Work page that showcases our work.</p>
|
|
17
|
+
</lion-tabs>
|
|
18
|
+
`;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i --save @lion/ui
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { LionTabs } from '@lion/ui/tabs.js';
|
|
29
|
+
// or
|
|
30
|
+
import '@lion/ui/define/lion-tabs.js';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Rationale
|
|
34
|
+
|
|
35
|
+
### No separate active/focus state when using keyboard
|
|
36
|
+
|
|
37
|
+
We will immediately switch content as all our content comes from light dom (e.g. no latency)
|
|
38
|
+
|
|
39
|
+
See Note at <https://www.w3.org/TR/wai-aria-practices/#keyboard-interaction-19>
|
|
40
|
+
|
|
41
|
+
> It is recommended that tabs activate automatically when they receive focus as long as their
|
|
42
|
+
> associated tab panels are displayed without noticeable latency. This typically requires tab
|
|
43
|
+
> panel content to be preloaded.
|
|
44
|
+
|
|
45
|
+
### Panels are not focusable
|
|
46
|
+
|
|
47
|
+
Focusable elements should have a means to interact with them. Tab panels themselves do not offer any interactivity.
|
|
48
|
+
If there is a button or a form inside the tab panel then these elements get focused directly.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class LeaTabPanel extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return css`
|
|
6
|
+
:host {
|
|
7
|
+
background-color: #fff;
|
|
8
|
+
background-image: linear-gradient(top, #fff, #ddd);
|
|
9
|
+
border-radius: 0 2px 2px 2px;
|
|
10
|
+
box-shadow: 0 2px 2px #000, 0 -1px 0 #fff inset;
|
|
11
|
+
padding: 30px;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
render() {
|
|
17
|
+
return html`
|
|
18
|
+
<!-- dom as needed -->
|
|
19
|
+
<slot></slot>
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
customElements.define('lea-tab-panel', LeaTabPanel);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class LeaTab extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return css`
|
|
6
|
+
:host {
|
|
7
|
+
box-shadow: -4px 0 0 rgba(0, 0, 0, 0.2);
|
|
8
|
+
background: #ad1c1c;
|
|
9
|
+
background: linear-gradient(220deg, transparent 10px, #ad1c1c 10px);
|
|
10
|
+
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
|
|
11
|
+
color: #fff;
|
|
12
|
+
float: left;
|
|
13
|
+
font: bold 12px/35px 'Lucida sans', Arial, Helvetica;
|
|
14
|
+
height: 35px;
|
|
15
|
+
padding: 0 30px;
|
|
16
|
+
text-decoration: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host(:hover) {
|
|
20
|
+
background: #c93434;
|
|
21
|
+
background: linear-gradient(220deg, transparent 10px, #c93434 10px);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host(:focus) {
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
box-shadow: 0 0 8px #9fcaea, 0 0 0 1px #559bd1;
|
|
27
|
+
|
|
28
|
+
/* outline: 0; */
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([selected]) {
|
|
32
|
+
background: #fff;
|
|
33
|
+
background: linear-gradient(220deg, transparent 10px, #fff 10px);
|
|
34
|
+
text-shadow: none;
|
|
35
|
+
color: #333;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
return html`<slot></slot>`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
customElements.define('lea-tab', LeaTab);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { LionTabs } from '@lion/ui/tabs.js';
|
|
3
|
+
|
|
4
|
+
export class LeaTabs extends LionTabs {
|
|
5
|
+
static get styles() {
|
|
6
|
+
return [
|
|
7
|
+
...super.styles,
|
|
8
|
+
css`
|
|
9
|
+
:host {
|
|
10
|
+
background: #222;
|
|
11
|
+
display: block;
|
|
12
|
+
padding: 20px;
|
|
13
|
+
}
|
|
14
|
+
`,
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
this._setupFeature();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_setupFeature() {
|
|
24
|
+
// being awesome
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
customElements.define('lea-tabs', LeaTabs);
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Tabs >> Use Cases ||20
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { LitElement, html } from '@mdjs/mdjs-preview';
|
|
5
|
+
|
|
6
|
+
import '@lion/ui/define/lion-tabs.js';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Selected Index
|
|
10
|
+
|
|
11
|
+
You can set the `selectedIndex` to select a certain tab.
|
|
12
|
+
|
|
13
|
+
```js preview-story
|
|
14
|
+
export const selectedIndex = () => html`
|
|
15
|
+
<lion-tabs .selectedIndex=${1}>
|
|
16
|
+
<button slot="tab">Info</button>
|
|
17
|
+
<p slot="panel">Info page with lots of information about us.</p>
|
|
18
|
+
<button slot="tab">Work</button>
|
|
19
|
+
<p slot="panel">Work page that showcases our work.</p>
|
|
20
|
+
</lion-tabs>
|
|
21
|
+
`;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Slots Order
|
|
25
|
+
|
|
26
|
+
The tab and panel slots are ordered by DOM order.
|
|
27
|
+
|
|
28
|
+
This means you can switch the grouping in your `lion-tabs` from tab + panel to all tabs first or all panels first.
|
|
29
|
+
|
|
30
|
+
```js preview-story
|
|
31
|
+
export const slotsOrder = () => html`
|
|
32
|
+
<lion-tabs>
|
|
33
|
+
<button slot="tab">Info</button>
|
|
34
|
+
<button slot="tab">Work</button>
|
|
35
|
+
<p slot="panel">Info page with lots of information about us.</p>
|
|
36
|
+
<p slot="panel">Work page that showcases our work.</p>
|
|
37
|
+
</lion-tabs>
|
|
38
|
+
`;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Disabled tabs
|
|
42
|
+
|
|
43
|
+
You can disable specific tabs by adding the `disabled` attribute to a tab button.
|
|
44
|
+
|
|
45
|
+
When using the arrow keys to switch tabs, it will skip disabled tabs, but it will not cycle from last to first or vice versa.
|
|
46
|
+
|
|
47
|
+
```js preview-story
|
|
48
|
+
export const tabsDisabled = () => html`
|
|
49
|
+
<lion-tabs>
|
|
50
|
+
<button slot="tab">tab 1</button>
|
|
51
|
+
<div slot="panel">panel 1</div>
|
|
52
|
+
<button slot="tab" disabled>tab 2</button>
|
|
53
|
+
<div slot="panel">panel 2</div>
|
|
54
|
+
<button slot="tab" disabled>tab 3</button>
|
|
55
|
+
<div slot="panel">panel 3</div>
|
|
56
|
+
<button slot="tab">tab 4</button>
|
|
57
|
+
<div slot="panel">panel 4</div>
|
|
58
|
+
<button slot="tab">tab 5</button>
|
|
59
|
+
<div slot="panel">panel 5</div>
|
|
60
|
+
<button slot="tab" disabled>tab 6</button>
|
|
61
|
+
<div slot="panel">panel 6</div>
|
|
62
|
+
</lion-tabs>
|
|
63
|
+
`;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Nesting tabs
|
|
67
|
+
|
|
68
|
+
You can include tabs within tabs
|
|
69
|
+
|
|
70
|
+
```js preview-story
|
|
71
|
+
export const nestedTabs = () => html`
|
|
72
|
+
<lion-tabs>
|
|
73
|
+
<button slot="tab">Movies</button>
|
|
74
|
+
<button slot="tab">Work</button>
|
|
75
|
+
<div slot="panel">
|
|
76
|
+
<p>Find some more info about our favorite movies:</p>
|
|
77
|
+
<lion-tabs>
|
|
78
|
+
<button slot="tab">Info about Cars</button>
|
|
79
|
+
<button slot="tab">Info about Toy Story</button>
|
|
80
|
+
<p slot="panel">
|
|
81
|
+
Cars is a 2006 American computer-animated comedy film produced by Pixar Animation Studios
|
|
82
|
+
and released by Walt Disney Pictures.
|
|
83
|
+
</p>
|
|
84
|
+
<p slot="panel">
|
|
85
|
+
The feature film directorial debut of John Lasseter, it was the first entirely
|
|
86
|
+
computer-animated feature film, as well as the first feature film from Pixar.
|
|
87
|
+
</p>
|
|
88
|
+
</lion-tabs>
|
|
89
|
+
</div>
|
|
90
|
+
<p slot="panel">Work page that showcases our work.</p>
|
|
91
|
+
</lion-tabs>
|
|
92
|
+
`;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Distribute New Elements
|
|
96
|
+
|
|
97
|
+
Below, we demonstrate on how you could dynamically add new tab + panels.
|
|
98
|
+
|
|
99
|
+
```js preview-story
|
|
100
|
+
export const distributeNewElement = () => {
|
|
101
|
+
const tagName = 'demo-tabs-add-dynamically';
|
|
102
|
+
if (!customElements.get(tagName)) {
|
|
103
|
+
customElements.define(
|
|
104
|
+
tagName,
|
|
105
|
+
class extends LitElement {
|
|
106
|
+
static get properties() {
|
|
107
|
+
return {
|
|
108
|
+
__collection: { type: Array },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
render() {
|
|
112
|
+
return html`
|
|
113
|
+
<h3>Append</h3>
|
|
114
|
+
<lion-tabs id="appendTabs">
|
|
115
|
+
<button slot="tab">tab 1</button>
|
|
116
|
+
<p slot="panel">panel 1</p>
|
|
117
|
+
<button slot="tab">tab 2</button>
|
|
118
|
+
<p slot="panel">panel 2</p>
|
|
119
|
+
</lion-tabs>
|
|
120
|
+
<button @click="${this.__handleAppendClick}">Append</button>
|
|
121
|
+
<hr />
|
|
122
|
+
<h3>Push</h3>
|
|
123
|
+
<lion-tabs id="pushTabs">
|
|
124
|
+
<button slot="tab">tab 1</button>
|
|
125
|
+
<p slot="panel">panel 1</p>
|
|
126
|
+
<button slot="tab">tab 2</button>
|
|
127
|
+
<p slot="panel">panel 2</p>
|
|
128
|
+
${this.__collection.map(
|
|
129
|
+
item => html`
|
|
130
|
+
<button slot="tab">${item.button}</button>
|
|
131
|
+
<p slot="panel">${item.panel}</p>
|
|
132
|
+
`,
|
|
133
|
+
)}
|
|
134
|
+
</lion-tabs>
|
|
135
|
+
<button @click="${this.__handlePushClick}">Push</button>
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
constructor() {
|
|
139
|
+
super();
|
|
140
|
+
this.__collection = [];
|
|
141
|
+
}
|
|
142
|
+
__handleAppendClick() {
|
|
143
|
+
const tabsElement = this.shadowRoot.querySelector('#appendTabs');
|
|
144
|
+
const c = 2;
|
|
145
|
+
const n = Math.floor(tabsElement.children.length / 2);
|
|
146
|
+
for (let i = n + 1; i < n + c; i += 1) {
|
|
147
|
+
const tab = document.createElement('button');
|
|
148
|
+
tab.setAttribute('slot', 'tab');
|
|
149
|
+
tab.innerText = `tab ${i}`;
|
|
150
|
+
const panel = document.createElement('p');
|
|
151
|
+
panel.setAttribute('slot', 'panel');
|
|
152
|
+
panel.innerText = `panel ${i}`;
|
|
153
|
+
tabsElement.append(tab);
|
|
154
|
+
tabsElement.append(panel);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
__handlePushClick() {
|
|
158
|
+
const tabsElement = this.shadowRoot.querySelector('#pushTabs');
|
|
159
|
+
const i = Math.floor(tabsElement.children.length / 2) + 1;
|
|
160
|
+
this.__collection = [
|
|
161
|
+
...this.__collection,
|
|
162
|
+
{
|
|
163
|
+
button: `tab ${i}`,
|
|
164
|
+
panel: `panel ${i}`,
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return html` <demo-tabs-add-dynamically></demo-tabs-add-dynamically> `;
|
|
172
|
+
};
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
One way is by creating the DOM elements and appending them as needed.
|
|
176
|
+
|
|
177
|
+
Inside your `lion-tabs` extension, an example for appending nodes on a certain button click:
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
__handleAppendClick() {
|
|
181
|
+
const tabsAmount = this.children.length / 2;
|
|
182
|
+
const tab = document.createElement('button');
|
|
183
|
+
tab.setAttribute('slot', 'tab');
|
|
184
|
+
tab.innerText = `tab ${tabsAmount + 1}`;
|
|
185
|
+
const panel = document.createElement('p');
|
|
186
|
+
panel.setAttribute('slot', 'panel');
|
|
187
|
+
panel.innerText = `panel ${tabsAmount + 1}`;
|
|
188
|
+
this.append(tab);
|
|
189
|
+
this.append(panel);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The other way is by adding data to a Lit property where you loop over this property in your template.
|
|
194
|
+
You then need to ensure this causes a re-render.
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
__handlePushClick() {
|
|
198
|
+
const tabsAmount = this.children.length;
|
|
199
|
+
myCollection = [
|
|
200
|
+
...myCollection,
|
|
201
|
+
{
|
|
202
|
+
button: `tab ${tabsAmount + 1}`,
|
|
203
|
+
panel: `panel ${tabsAmount + 1}`,
|
|
204
|
+
},
|
|
205
|
+
];
|
|
206
|
+
renderMyCollection();
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Make sure your template re-renders when myCollection is updated.
|
|
211
|
+
|
|
212
|
+
```html
|
|
213
|
+
<lion-tabs id="pushTabs">
|
|
214
|
+
${myCollection.map(item => html`
|
|
215
|
+
<button slot="tab">${item.button}</button>
|
|
216
|
+
<p slot="panel">${item.panel}</p>
|
|
217
|
+
`)}
|
|
218
|
+
</lion-tabs>
|
|
219
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Textarea >> Overview ||10
|
|
2
|
+
|
|
3
|
+
A webcomponent that enhances the functionality of the native `<input type="textarea">` element.
|
|
4
|
+
Its purpose is to provide a way for users to write text that is multiple lines long.
|
|
5
|
+
|
|
6
|
+
```js script
|
|
7
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
8
|
+
import '@lion/ui/define/lion-textarea.js';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```js preview-story
|
|
12
|
+
export const main = () => html`
|
|
13
|
+
<lion-textarea label="Stops growing after 4 rows" max-rows="4"></lion-textarea>
|
|
14
|
+
`;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- Default rows is 2 and it will grow to max-rows of 6.
|
|
20
|
+
- `max-rows` attribute to set the amount of rows it should resize to, before it will scroll
|
|
21
|
+
- `rows` attribute to set the minimum amount of rows
|
|
22
|
+
- `readonly` attribute to prevent changing the content
|
|
23
|
+
- Uses Intersection Observer for detecting visibility change, making sure it resizes
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm i --save @lion/ui
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import { LionTextarea } from '@lion/ui/textarea.js';
|
|
33
|
+
// or
|
|
34
|
+
import '@lion/ui/define/lion-textarea.js';
|
|
35
|
+
```
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Textarea >> Use Cases ||20
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
5
|
+
import '@lion/ui/define/lion-textarea.js';
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Prefilled
|
|
9
|
+
|
|
10
|
+
You can prefill the textarea. If you want to prefill on multiline, you will have to add newline characters `'\n'`.
|
|
11
|
+
|
|
12
|
+
```js preview-story
|
|
13
|
+
export const prefilled = () => html`
|
|
14
|
+
<lion-textarea
|
|
15
|
+
label="Prefilled"
|
|
16
|
+
.modelValue=${['batman', 'and', 'robin'].join('\n')}
|
|
17
|
+
></lion-textarea>
|
|
18
|
+
`;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Disabled
|
|
22
|
+
|
|
23
|
+
The textarea can be disabled with the `disabled` attribute.
|
|
24
|
+
|
|
25
|
+
```js preview-story
|
|
26
|
+
export const disabled = () => html` <lion-textarea label="Disabled" disabled></lion-textarea> `;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Readonly
|
|
30
|
+
|
|
31
|
+
`readonly` attribute indicate that you can't change the content. Compared with `disabled` attribute, the `readonly` attribute doesn't prevent clicking or selecting the element.
|
|
32
|
+
|
|
33
|
+
```js preview-story
|
|
34
|
+
export const readonly = () => html`
|
|
35
|
+
<lion-textarea
|
|
36
|
+
label="Readonly"
|
|
37
|
+
readonly
|
|
38
|
+
.modelValue=${['batman', 'and', 'robin'].join('\n')}
|
|
39
|
+
></lion-textarea>
|
|
40
|
+
`;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Stop growing
|
|
44
|
+
|
|
45
|
+
Use the `max-rows` attribute to make it stop growing after a certain amount of lines.
|
|
46
|
+
|
|
47
|
+
```js preview-story
|
|
48
|
+
export const stopGrowing = () => html`
|
|
49
|
+
<lion-textarea
|
|
50
|
+
label="Stop growing"
|
|
51
|
+
max-rows="4"
|
|
52
|
+
.modelValue=${['batman', 'and', 'robin'].join('\n')}
|
|
53
|
+
></lion-textarea>
|
|
54
|
+
`;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Non-growing
|
|
58
|
+
|
|
59
|
+
To have a fixed size provide `rows` and `max-rows` with the same value.
|
|
60
|
+
|
|
61
|
+
```js preview-story
|
|
62
|
+
export const nonGrowing = () => html`
|
|
63
|
+
<lion-textarea label="Non Growing" rows="3" max-rows="3"></lion-textarea>
|
|
64
|
+
`;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Intersection Observer
|
|
68
|
+
|
|
69
|
+
It could be that your textarea is inside a hidden container, for example for a dialog or accordion or tabs.
|
|
70
|
+
When it is hidden, the resizing is calculated based on the visible space of the text.
|
|
71
|
+
Therefore, an Intersection Observer observes visibility changes of the textarea relative to the viewport, and resizes the textarea when a visibility change happens.
|
|
72
|
+
|
|
73
|
+
> For old browsers like old Edge or IE11, a [polyfill](https://github.com/w3c/IntersectionObserver/tree/master/polyfill) is required to be added on the application level for this to work.
|
|
74
|
+
> For most cases, the optimized default will suffice.
|
|
75
|
+
|
|
76
|
+
In the demo below you can see that the textarea is correctly calculated to 4 maximum rows, whereas without the observer, it would be on 2 rows and only resize on user input.
|
|
77
|
+
|
|
78
|
+
```js preview-story
|
|
79
|
+
export const hidden = () => html`
|
|
80
|
+
<div style="display: none">
|
|
81
|
+
<lion-textarea
|
|
82
|
+
.modelValue="${'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'}"
|
|
83
|
+
label="Stops growing after 4 rows"
|
|
84
|
+
max-rows="4"
|
|
85
|
+
></lion-textarea>
|
|
86
|
+
</div>
|
|
87
|
+
<button
|
|
88
|
+
@click=${e =>
|
|
89
|
+
(e.target.previousElementSibling.style.display =
|
|
90
|
+
e.target.previousElementSibling.style.display === 'block' ? 'none' : 'block')}
|
|
91
|
+
>
|
|
92
|
+
Toggle display
|
|
93
|
+
</button>
|
|
94
|
+
`;
|
|
95
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Tooltip >> Examples ||30
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
5
|
+
import '@lion/ui/define/lion-tooltip.js';
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
```js preview-story
|
|
9
|
+
export const main = () => html`
|
|
10
|
+
<style>
|
|
11
|
+
.demo-tooltip-invoker {
|
|
12
|
+
margin: 50px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.demo-tooltip-content {
|
|
16
|
+
display: block;
|
|
17
|
+
font-size: 16px;
|
|
18
|
+
color: white;
|
|
19
|
+
background-color: black;
|
|
20
|
+
border-radius: 4px;
|
|
21
|
+
padding: 8px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.demo-box-placements {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
margin: 40px 0 0 200px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.demo-box-placements lion-tooltip {
|
|
31
|
+
margin: 20px;
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
34
|
+
<lion-tooltip has-arrow>
|
|
35
|
+
<button slot="invoker" class="demo-tooltip-invoker">Hover me</button>
|
|
36
|
+
<div slot="content" class="demo-tooltip-content">This is a tooltip</div>
|
|
37
|
+
</lion-tooltip>
|
|
38
|
+
`;
|
|
39
|
+
```
|