@govtechsg/sgds-web-component 0.0.10 → 0.0.12
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/README.md +102 -10
- package/base/card-element.d.ts +12 -0
- package/{lib/utils → base}/dropdown-element.d.ts +38 -37
- package/{lib/utils → base}/link-element.d.ts +8 -7
- package/{lib/utils → base}/sgds-element.d.ts +6 -5
- package/components/Accordion/index.d.ts +2 -0
- package/components/Accordion/sgds-accordion-item.d.ts +40 -0
- package/components/Accordion/sgds-accordion.d.ts +19 -0
- package/components/ActionCard/index.d.ts +1 -0
- package/{lib/Card → components/ActionCard}/sgds-action-card.d.ts +21 -20
- package/components/Alert/index.d.ts +1 -0
- package/components/Alert/sgds-alert.d.ts +37 -0
- package/components/Badge/index.d.ts +1 -0
- package/components/Badge/sgds-badge.d.ts +10 -0
- package/components/Breadcrumb/index.d.ts +2 -0
- package/components/Breadcrumb/sgds-breadcrumb-item.d.ts +10 -0
- package/components/Breadcrumb/sgds-breadcrumb.d.ts +12 -0
- package/components/Button/index.d.ts +1 -0
- package/{lib → components}/Button/sgds-button.d.ts +55 -48
- package/components/Checkbox/index.d.ts +1 -0
- package/{lib → components}/Checkbox/sgds-checkbox.d.ts +36 -36
- package/components/CloseButton/index.d.ts +1 -0
- package/components/CloseButton/sgds-closebutton.d.ts +9 -0
- package/components/Dropdown/index.d.ts +3 -0
- package/{lib → components}/Dropdown/sgds-dropdown-item.d.ts +8 -7
- package/{lib → components}/Dropdown/sgds-dropdown.d.ts +8 -7
- package/components/FileUpload/index.d.ts +1 -0
- package/components/FileUpload/sgds-fileupload.d.ts +22 -0
- package/components/Footer/index.d.ts +1 -0
- package/{lib → components}/Footer/sgds-footer.d.ts +27 -23
- package/components/Input/index.d.ts +1 -0
- package/{lib → components}/Input/sgds-input.d.ts +42 -42
- package/components/Mainnav/index.d.ts +3 -0
- package/components/Mainnav/sgds-mainnav-dropdown.d.ts +6 -0
- package/components/Mainnav/sgds-mainnav-item.d.ts +8 -0
- package/{lib → components}/Mainnav/sgds-mainnav.d.ts +26 -22
- package/components/Masthead/index.d.ts +1 -0
- package/{lib → components}/Masthead/sgds-masthead.d.ts +9 -12
- package/components/Modal/index.d.ts +1 -0
- package/{lib → components}/Modal/sgds-modal.d.ts +28 -28
- package/components/QuantityToggle/index.d.ts +1 -0
- package/{lib/QuantityToggle/sgds-quantitytoggle.d.ts → components/QuantityToggle/sgds-quantity-toggle.d.ts} +30 -30
- package/components/Radio/index.d.ts +2 -0
- package/{lib/Radio/sgds-radiogroup.d.ts → components/Radio/sgds-radio-group.d.ts} +41 -41
- package/{lib → components}/Radio/sgds-radio.d.ts +31 -31
- package/components/Sidenav/index.d.ts +3 -0
- package/{lib → components}/Sidenav/sgds-sidenav-item.d.ts +36 -28
- package/components/Sidenav/sgds-sidenav-link.d.ts +8 -0
- package/{lib → components}/Sidenav/sgds-sidenav.d.ts +10 -6
- package/components/Stepper/index.d.ts +1 -0
- package/components/Stepper/sgds-stepper.d.ts +17 -0
- package/components/Tab/index.d.ts +3 -0
- package/{lib → components}/Tab/sgds-tab.d.ts +27 -26
- package/{lib → components}/Tab/sgds-tabgroup.d.ts +48 -47
- package/{lib → components}/Tab/sgds-tabpanel.d.ts +26 -25
- package/components/Table/index.d.ts +1 -0
- package/components/Table/sgds-table.d.ts +26 -0
- package/components/Textarea/index.d.ts +1 -0
- package/{lib → components}/Textarea/sgds-textarea.d.ts +53 -53
- package/components/Toast/index.d.ts +1 -0
- package/components/Toast/sgds-toast.d.ts +22 -0
- package/components/Tooltip/index.d.ts +1 -0
- package/components/Tooltip/sgds-tooltip.d.ts +30 -0
- package/index.d.ts +23 -0
- package/index.js +11543 -0
- package/index.js.map +1 -0
- package/main.d.ts +24 -0
- package/package.json +23 -65
- package/react/accordion/index.d.ts +3 -0
- package/react/accordion-item/index.d.ts +8 -0
- package/react/action-card/index.d.ts +3 -0
- package/react/alert/index.d.ts +3 -0
- package/react/badge/index.d.ts +3 -0
- package/react/breadcrumb/index.d.ts +3 -0
- package/react/breadcrumb-item/index.d.ts +3 -0
- package/react/button/index.d.ts +6 -0
- package/react/checkbox/index.d.ts +3 -0
- package/react/cjs/index.js +12510 -0
- package/react/cjs/index.js.map +1 -0
- package/react/closebutton/index.d.ts +5 -0
- package/react/dropdown/index.d.ts +3 -0
- package/react/dropdown-item/index.d.ts +3 -0
- package/react/fileupload/index.d.ts +3 -0
- package/react/footer/index.d.ts +3 -0
- package/react/index.d.ts +34 -0
- package/react/index.js +12453 -0
- package/react/index.js.map +1 -0
- package/react/input/index.d.ts +3 -0
- package/react/mainnav/index.d.ts +3 -0
- package/react/mainnav-dropdown/index.d.ts +3 -0
- package/react/mainnav-item/index.d.ts +3 -0
- package/react/masthead/index.d.ts +3 -0
- package/react/modal/index.d.ts +3 -0
- package/react/package.json +10 -0
- package/react/quantity-toggle/index.d.ts +3 -0
- package/react/radio/index.d.ts +3 -0
- package/react/radio-group/index.d.ts +3 -0
- package/react/sidenav/index.d.ts +3 -0
- package/react/sidenav-item/index.d.ts +5 -0
- package/react/sidenav-link/index.d.ts +3 -0
- package/react/stepper/index.d.ts +3 -0
- package/react/tab/index.d.ts +3 -0
- package/react/tab-group/index.d.ts +3 -0
- package/react/tab-panel/index.d.ts +3 -0
- package/react/table/index.d.ts +3 -0
- package/react/textarea/index.d.ts +3 -0
- package/react/toast/index.d.ts +3 -0
- package/react/tooltip/index.d.ts +3 -0
- package/umd/index.js +11995 -0
- package/umd/index.js.map +1 -0
- package/{lib/utils → utils}/animate.d.ts +10 -10
- package/{lib/utils → utils}/animation-registry.d.ts +18 -18
- package/{lib/utils → utils}/breakpoints.d.ts +5 -5
- package/{lib/utils → utils}/defaultvalue.d.ts +2 -2
- package/{lib/utils → utils}/event.d.ts +2 -2
- package/{lib/utils → utils}/form.d.ts +38 -38
- package/{lib/utils → utils}/generateId.d.ts +1 -1
- package/{lib/utils → utils}/mergeDeep.d.ts +2 -2
- package/{lib/utils → utils}/modal.d.ts +12 -12
- package/{lib/utils → utils}/object.d.ts +2 -2
- package/{lib/utils → utils}/offset.d.ts +4 -4
- package/{lib/utils → utils}/scroll.d.ts +13 -13
- package/{lib/utils → utils}/slot.d.ts +22 -22
- package/{lib/utils → utils}/tabbable.d.ts +8 -8
- package/{lib/utils → utils}/watch.d.ts +14 -14
- package/.github/workflows/publish-latest.yml +0 -22
- package/.github/workflows/publish-pr.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/prepare-commit-msg +0 -8
- package/.storybook/main.js +0 -16
- package/.storybook/preview-head.html +0 -11
- package/.storybook/preview.js +0 -9
- package/.vscode/settings.json +0 -7
- package/CONTRIBUTING.md +0 -56
- package/LICENSE +0 -20
- package/amplify.yml +0 -22
- package/commitlint.config.js +0 -1
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/button-element.scss.html +0 -112
- package/coverage/lcov-report/button-element.ts.html +0 -145
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -116
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -32
- package/index.html +0 -430
- package/lib/Button/index.d.ts +0 -1
- package/lib/Button/index.js +0 -6634
- package/lib/Button/index.js.map +0 -1
- package/lib/Button/package.json +0 -7
- package/lib/Card/index.d.ts +0 -1
- package/lib/Card/index.js +0 -6150
- package/lib/Card/index.js.map +0 -1
- package/lib/Card/package.json +0 -7
- package/lib/Checkbox/index.d.ts +0 -1
- package/lib/Checkbox/index.js +0 -6366
- package/lib/Checkbox/index.js.map +0 -1
- package/lib/Checkbox/package.json +0 -7
- package/lib/Dropdown/index.d.ts +0 -3
- package/lib/Dropdown/index.js +0 -13502
- package/lib/Dropdown/index.js.map +0 -1
- package/lib/Dropdown/package.json +0 -7
- package/lib/Footer/index.d.ts +0 -2
- package/lib/Footer/index.js +0 -7168
- package/lib/Footer/index.js.map +0 -1
- package/lib/Footer/package.json +0 -7
- package/lib/Input/index.d.ts +0 -1
- package/lib/Input/index.js +0 -6656
- package/lib/Input/index.js.map +0 -1
- package/lib/Input/package.json +0 -7
- package/lib/Mainnav/index.d.ts +0 -4
- package/lib/Mainnav/index.js +0 -32546
- package/lib/Mainnav/index.js.map +0 -1
- package/lib/Mainnav/package.json +0 -7
- package/lib/Mainnav/sgds-mainnav-dropdown.d.ts +0 -5
- package/lib/Mainnav/sgds-mainnav-item.d.ts +0 -4
- package/lib/Masthead/index.d.ts +0 -1
- package/lib/Masthead/index.js +0 -7371
- package/lib/Masthead/index.js.map +0 -1
- package/lib/Masthead/package.json +0 -7
- package/lib/Modal/index.d.ts +0 -1
- package/lib/Modal/index.js +0 -6432
- package/lib/Modal/index.js.map +0 -1
- package/lib/Modal/package.json +0 -7
- package/lib/QuantityToggle/index.d.ts +0 -1
- package/lib/QuantityToggle/index.js +0 -7049
- package/lib/QuantityToggle/index.js.map +0 -1
- package/lib/QuantityToggle/package.json +0 -7
- package/lib/Radio/index.d.ts +0 -2
- package/lib/Radio/index.js +0 -12607
- package/lib/Radio/index.js.map +0 -1
- package/lib/Radio/package.json +0 -7
- package/lib/Sidenav/index.d.ts +0 -3
- package/lib/Sidenav/index.js +0 -18739
- package/lib/Sidenav/index.js.map +0 -1
- package/lib/Sidenav/package.json +0 -7
- package/lib/Sidenav/sgds-sidenav-link.d.ts +0 -4
- package/lib/Tab/index.d.ts +0 -3
- package/lib/Tab/index.js +0 -13557
- package/lib/Tab/index.js.map +0 -1
- package/lib/Tab/package.json +0 -7
- package/lib/Textarea/index.d.ts +0 -1
- package/lib/Textarea/index.js +0 -6696
- package/lib/Textarea/index.js.map +0 -1
- package/lib/Textarea/package.json +0 -7
- package/lib/index.d.ts +0 -16
- package/lib/index.js +0 -134580
- package/lib/index.js.map +0 -1
- package/lib/umd/index.js +0 -134587
- package/lib/umd/index.js.map +0 -1
- package/lib/utils/card-element.d.ts +0 -11
- package/mocks/dropdown.d.ts +0 -4
- package/mocks/dropdown.ts +0 -27
- package/mocks/link.d.ts +0 -3
- package/mocks/link.ts +0 -6
- package/rollup.config.js +0 -73
- package/rollup.test.config.js +0 -42
- package/scripts/buildUtils.js +0 -30
- package/scripts/frankBuild.js +0 -49
- package/src/Button/index.ts +0 -1
- package/src/Button/sgds-button.scss +0 -28
- package/src/Button/sgds-button.ts +0 -153
- package/src/Card/index.ts +0 -1
- package/src/Card/sgds-action-card.scss +0 -27
- package/src/Card/sgds-action-card.ts +0 -115
- package/src/Checkbox/index.ts +0 -1
- package/src/Checkbox/sgds-checkbox.scss +0 -4
- package/src/Checkbox/sgds-checkbox.ts +0 -149
- package/src/Dropdown/index.ts +0 -3
- package/src/Dropdown/sgds-dropdown-item.ts +0 -39
- package/src/Dropdown/sgds-dropdown.scss +0 -5
- package/src/Dropdown/sgds-dropdown.ts +0 -54
- package/src/Footer/index.ts +0 -3
- package/src/Footer/sgds-footer.scss +0 -5
- package/src/Footer/sgds-footer.ts +0 -121
- package/src/Input/index.ts +0 -1
- package/src/Input/sgds-input.scss +0 -20
- package/src/Input/sgds-input.ts +0 -178
- package/src/Mainnav/index.ts +0 -4
- package/src/Mainnav/sgds-mainnav-dropdown.scss +0 -13
- package/src/Mainnav/sgds-mainnav-dropdown.ts +0 -45
- package/src/Mainnav/sgds-mainnav-item.scss +0 -24
- package/src/Mainnav/sgds-mainnav-item.ts +0 -8
- package/src/Mainnav/sgds-mainnav.scss +0 -39
- package/src/Mainnav/sgds-mainnav.ts +0 -183
- package/src/Masthead/index.ts +0 -1
- package/src/Masthead/sgds-masthead.scss +0 -217
- package/src/Masthead/sgds-masthead.ts +0 -189
- package/src/Modal/index.ts +0 -1
- package/src/Modal/sgds-modal.scss +0 -128
- package/src/Modal/sgds-modal.ts +0 -309
- package/src/QuantityToggle/index.ts +0 -1
- package/src/QuantityToggle/sgds-quantitytoggle.scss +0 -10
- package/src/QuantityToggle/sgds-quantitytoggle.ts +0 -130
- package/src/Radio/index.ts +0 -2
- package/src/Radio/sgds-radio.scss +0 -5
- package/src/Radio/sgds-radio.ts +0 -120
- package/src/Radio/sgds-radiogroup.scss +0 -22
- package/src/Radio/sgds-radiogroup.ts +0 -221
- package/src/Sidenav/index.ts +0 -4
- package/src/Sidenav/sgds-sidenav-item.scss +0 -73
- package/src/Sidenav/sgds-sidenav-item.ts +0 -145
- package/src/Sidenav/sgds-sidenav-link.scss +0 -25
- package/src/Sidenav/sgds-sidenav-link.ts +0 -8
- package/src/Sidenav/sgds-sidenav.scss +0 -6
- package/src/Sidenav/sgds-sidenav.ts +0 -33
- package/src/Tab/index.ts +0 -3
- package/src/Tab/sgds-tab.scss +0 -84
- package/src/Tab/sgds-tab.ts +0 -87
- package/src/Tab/sgds-tabgroup.scss +0 -198
- package/src/Tab/sgds-tabgroup.ts +0 -295
- package/src/Tab/sgds-tabpanel.scss +0 -12
- package/src/Tab/sgds-tabpanel.ts +0 -55
- package/src/Textarea/index.ts +0 -1
- package/src/Textarea/sgds-textarea.scss +0 -23
- package/src/Textarea/sgds-textarea.ts +0 -201
- package/src/index.ts +0 -16
- package/src/utils/animate.ts +0 -69
- package/src/utils/animation-registry.ts +0 -71
- package/src/utils/base.scss +0 -14
- package/src/utils/breakpoints.ts +0 -5
- package/src/utils/card-element.ts +0 -42
- package/src/utils/components.style.scss +0 -531
- package/src/utils/defaultvalue.ts +0 -51
- package/src/utils/dropdown-element.ts +0 -244
- package/src/utils/event.ts +0 -13
- package/src/utils/form.ts +0 -183
- package/src/utils/generateId.ts +0 -4
- package/src/utils/link-element.ts +0 -34
- package/src/utils/mergeDeep.ts +0 -22
- package/src/utils/modal.ts +0 -64
- package/src/utils/object.ts +0 -2
- package/src/utils/offset.ts +0 -6
- package/src/utils/scroll.ts +0 -57
- package/src/utils/sgds-element.ts +0 -18
- package/src/utils/slot.ts +0 -102
- package/src/utils/tabbable.ts +0 -81
- package/src/utils/watch.ts +0 -62
- package/stories/ActionCard.stories.mdx +0 -199
- package/stories/Button.stories.mdx +0 -194
- package/stories/Checkbox.stories.mdx +0 -196
- package/stories/Dropdown.stories.mdx +0 -152
- package/stories/Footer.stories.mdx +0 -261
- package/stories/Input.stories.mdx +0 -236
- package/stories/MainNav.stories.mdx +0 -169
- package/stories/Masthead.stories.mdx +0 -112
- package/stories/Modal.stories.mdx +0 -103
- package/stories/QuantityToggle.stories.mdx +0 -97
- package/stories/Radio.stories.mdx +0 -262
- package/stories/Sample.stories.js +0 -29
- package/stories/Sample.stories.mdx +0 -33
- package/stories/SideNav.stories.mdx +0 -245
- package/stories/common.js +0 -185
- package/stories/textarea.stories.mdx +0 -253
- package/test/button.element.test.ts +0 -185
- package/test/checkbox.test.ts +0 -240
- package/test/dropdown.test.ts +0 -637
- package/test/footer.test.ts +0 -181
- package/test/generateId.test.ts +0 -18
- package/test/input.element.test.ts +0 -316
- package/test/link-element.test.ts +0 -38
- package/test/mainnav.test.ts +0 -313
- package/test/masthead.test.ts +0 -116
- package/test/modal.test.ts +0 -149
- package/test/quantitytoggle.test.ts +0 -76
- package/test/radio.test.ts +0 -310
- package/test/selectable-card.test.ts +0 -159
- package/test/sidenav.test.ts +0 -390
- package/test/tab.test.ts +0 -76
- package/test/textarea.test.ts +0 -126
- package/tsconfig.json +0 -26
- package/tsconfig.test.json +0 -24
- package/typings/scss.d.ts +0 -5
- package/web-dev-server.config.mjs +0 -7
- package/web-test-runner.config.mjs +0 -47
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { LitElement, html } from "lit";
|
|
2
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
|
3
|
-
import { live } from "lit/directives/live.js";
|
|
4
|
-
import styles from "./sgds-checkbox.scss";
|
|
5
|
-
import { ifDefined } from "lit/directives/if-defined.js";
|
|
6
|
-
import SgdsElement from "../utils/sgds-element";
|
|
7
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
8
|
-
import genId from "../utils/generateId";
|
|
9
|
-
import { defaultValue } from "../utils/defaultvalue";
|
|
10
|
-
import { FormSubmitController } from "../utils/form";
|
|
11
|
-
import { watch } from "../utils/watch";
|
|
12
|
-
|
|
13
|
-
@customElement("sgds-checkbox")
|
|
14
|
-
export class SgdsCheckbox extends SgdsElement {
|
|
15
|
-
static styles = styles;
|
|
16
|
-
|
|
17
|
-
@query('input[type="checkbox"]') input: HTMLInputElement;
|
|
18
|
-
|
|
19
|
-
private readonly formSubmitController = new FormSubmitController(this, {
|
|
20
|
-
value: (control: SgdsCheckbox) =>
|
|
21
|
-
control.checked ? control.value : undefined,
|
|
22
|
-
defaultValue: (control: SgdsCheckbox) => control.defaultChecked,
|
|
23
|
-
setValue: (control: SgdsCheckbox, checked: boolean) =>
|
|
24
|
-
(control.checked = checked),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
/** Name of the HTML form control. Submitted with the form as part of a name/value pair. */
|
|
28
|
-
@property({reflect: true }) name: string;
|
|
29
|
-
|
|
30
|
-
/** For Id/For pair of the HTML form control. */
|
|
31
|
-
@property({ type: String, reflect: true }) checkboxId = genId("checkbox");
|
|
32
|
-
|
|
33
|
-
/** For aria-label when there is no appropriate text label visible */
|
|
34
|
-
@property({ type: String, reflect: true }) ariaLabel = "checkbox";
|
|
35
|
-
|
|
36
|
-
/** Manually style the input as valid */
|
|
37
|
-
@property({ type: Boolean, reflect: true }) valid = false;
|
|
38
|
-
|
|
39
|
-
/** Manually style the input as invalid */
|
|
40
|
-
@property({ type: Boolean, reflect: true }) invalid = false;
|
|
41
|
-
|
|
42
|
-
/** Value of the HTML form control. Primarily used to differentiate a list of related checkboxes that have the same name. */
|
|
43
|
-
@property() value: string;
|
|
44
|
-
|
|
45
|
-
/** Makes the checkbox a required field. */
|
|
46
|
-
@property({ type: Boolean, reflect: true }) required = false;
|
|
47
|
-
|
|
48
|
-
/** Draws the checkbox in a checked state. */
|
|
49
|
-
@property({ type: Boolean, reflect: true }) checked = false;
|
|
50
|
-
|
|
51
|
-
/** Disables the checkbox (so the user can't check / uncheck it). */
|
|
52
|
-
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
53
|
-
|
|
54
|
-
/** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
|
|
55
|
-
@defaultValue("checked")
|
|
56
|
-
defaultChecked = false;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/** Simulates a click on the checkbox. */
|
|
60
|
-
click() {
|
|
61
|
-
this.input.click();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
65
|
-
reportValidity() {
|
|
66
|
-
if (!this.input.reportValidity()) {
|
|
67
|
-
this.invalid = !this.input.checkValidity();
|
|
68
|
-
}
|
|
69
|
-
return this.input.reportValidity();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
handleChange() {
|
|
73
|
-
// console.log(
|
|
74
|
-
// "when this.click() is fired, input detects a change --> handleChange runs"
|
|
75
|
-
// );
|
|
76
|
-
this.checked = !this.checked;
|
|
77
|
-
this.value = this.input.value;
|
|
78
|
-
this.emit("sgds-change");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
handleKeyDown(event: KeyboardEvent) {
|
|
82
|
-
const hasModifier =
|
|
83
|
-
event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
84
|
-
if (event.key === "Enter" && !hasModifier) {
|
|
85
|
-
// console.log(
|
|
86
|
-
// "so here we are trying to mimick keydown enter event like a mousclick event"
|
|
87
|
-
// );
|
|
88
|
-
this.click();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@watch("disabled", { waitUntilFirstUpdate: true })
|
|
93
|
-
handleDisabledChange() {
|
|
94
|
-
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
95
|
-
this.input.disabled = this.disabled;
|
|
96
|
-
this.invalid = !this.input.checkValidity();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@watch("checked", { waitUntilFirstUpdate: true })
|
|
100
|
-
handleStateChange() {
|
|
101
|
-
this.invalid = !this.input.checkValidity();
|
|
102
|
-
if (this.required) this.valid = this.input.checkValidity();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
render() {
|
|
106
|
-
return html`
|
|
107
|
-
<div part="base" class="form-check">
|
|
108
|
-
<input
|
|
109
|
-
part="control"
|
|
110
|
-
class=${classMap({
|
|
111
|
-
"form-check-input": true,
|
|
112
|
-
"is-invalid": this.invalid,
|
|
113
|
-
"is-valid": this.valid,
|
|
114
|
-
})}
|
|
115
|
-
type="checkbox"
|
|
116
|
-
id=${ifDefined(this.checkboxId)}
|
|
117
|
-
aria-invalid=${this.invalid ? "true" : "false"}
|
|
118
|
-
name=${ifDefined(this.name)}
|
|
119
|
-
value=${ifDefined(this.value)}
|
|
120
|
-
.checked=${live(this.checked)}
|
|
121
|
-
?disabled=${this.disabled}
|
|
122
|
-
?required=${this.required}
|
|
123
|
-
aria-disabled=${this.disabled ? "true" : "false"}
|
|
124
|
-
aria-checked=${this.checked ? "true" : "false"}
|
|
125
|
-
@change=${this.handleChange}
|
|
126
|
-
@keydown=${this.handleKeyDown}
|
|
127
|
-
/>
|
|
128
|
-
<label
|
|
129
|
-
part="label"
|
|
130
|
-
for="${ifDefined(this.checkboxId)}"
|
|
131
|
-
aria-label=${ifDefined(this.ariaLabel)}
|
|
132
|
-
class="form-check-label"
|
|
133
|
-
><slot></slot
|
|
134
|
-
></label>
|
|
135
|
-
${this.invalid
|
|
136
|
-
? html`<slot
|
|
137
|
-
name="feedback"
|
|
138
|
-
part="feedback"
|
|
139
|
-
class=${classMap({
|
|
140
|
-
"invalid-feedback": true,
|
|
141
|
-
})}
|
|
142
|
-
></slot>`
|
|
143
|
-
: undefined}
|
|
144
|
-
</div>
|
|
145
|
-
`;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export default SgdsCheckbox;
|
package/src/Dropdown/index.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { customElement, property, query } from "lit/decorators.js";
|
|
3
|
-
import LinkElement from "../utils/link-element";
|
|
4
|
-
import styles from "./sgds-dropdown.scss";
|
|
5
|
-
import {classMap} from 'lit/directives/class-map.js';
|
|
6
|
-
|
|
7
|
-
@customElement("sgds-dropdown-item")
|
|
8
|
-
export class SgdsDropdownItem extends LinkElement {
|
|
9
|
-
static styles = styles
|
|
10
|
-
|
|
11
|
-
@query('a')
|
|
12
|
-
anchor: HTMLElement
|
|
13
|
-
firstUpdated(){
|
|
14
|
-
//required when navigate with ArrowDown/ArrowUp
|
|
15
|
-
this.addEventListener('keydown', (e:KeyboardEvent) => {
|
|
16
|
-
if (e.key === 'Enter') {
|
|
17
|
-
this.anchor.click()
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
render() {
|
|
23
|
-
return html`
|
|
24
|
-
<li>
|
|
25
|
-
<a
|
|
26
|
-
href="${this.href}"
|
|
27
|
-
class="dropdown-item ${classMap({
|
|
28
|
-
'disabled': this.disabled,
|
|
29
|
-
'active': this.active
|
|
30
|
-
})}"
|
|
31
|
-
?disabled=${this.disabled}
|
|
32
|
-
aria-disabled=${this.disabled ? 'true' : 'false'}
|
|
33
|
-
tabindex=${this.disabled ? '-1': '0'}
|
|
34
|
-
><slot></slot
|
|
35
|
-
></a>
|
|
36
|
-
</li>
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { customElement } from "lit/decorators.js";
|
|
3
|
-
import { ref } from "lit/directives/ref.js";
|
|
4
|
-
import styles from "./sgds-dropdown.scss";
|
|
5
|
-
import { DropdownElement } from "../utils/dropdown-element";
|
|
6
|
-
|
|
7
|
-
export type DropDirection = "left" | "right" | "up" | "down";
|
|
8
|
-
@customElement("sgds-dropdown")
|
|
9
|
-
export class SgdsDropdown extends DropdownElement {
|
|
10
|
-
static styles = styles;
|
|
11
|
-
constructor(){
|
|
12
|
-
super()
|
|
13
|
-
this.modifierOpt = [
|
|
14
|
-
{
|
|
15
|
-
name: "offset",
|
|
16
|
-
options: {
|
|
17
|
-
offset: [0, 10],
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
}
|
|
22
|
-
render() {
|
|
23
|
-
return html`
|
|
24
|
-
<div>
|
|
25
|
-
<sgds-button
|
|
26
|
-
variant="outline-${this.variant}"
|
|
27
|
-
?disabled=${this.disabled}
|
|
28
|
-
aria-expanded="${this.menuIsOpen}"
|
|
29
|
-
${ref(this.myDropdown)}
|
|
30
|
-
@click=${() => this._onClickButton()}
|
|
31
|
-
id=${this.togglerId}
|
|
32
|
-
>
|
|
33
|
-
${this.togglerText}
|
|
34
|
-
<svg
|
|
35
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
36
|
-
width="16"
|
|
37
|
-
height="16"
|
|
38
|
-
fill="currentColor"
|
|
39
|
-
class="bi bi-chevron-down"
|
|
40
|
-
viewBox="0 0 16 16"
|
|
41
|
-
>
|
|
42
|
-
<path
|
|
43
|
-
fill-rule="evenodd"
|
|
44
|
-
d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"
|
|
45
|
-
/>
|
|
46
|
-
</svg>
|
|
47
|
-
</sgds-button>
|
|
48
|
-
<ul class="dropdown-menu" role="menu" part="menu">
|
|
49
|
-
<slot @click=${this._handleSelectSlot}></slot>
|
|
50
|
-
</ul>
|
|
51
|
-
</div>
|
|
52
|
-
`;
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/Footer/index.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { customElement, property } from "lit/decorators.js";
|
|
3
|
-
import styles from "./sgds-footer.scss";
|
|
4
|
-
import SgdsElement from "../utils/sgds-element";
|
|
5
|
-
|
|
6
|
-
export type Links = {
|
|
7
|
-
href: string;
|
|
8
|
-
label: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ColumnLinks {
|
|
11
|
-
title: string;
|
|
12
|
-
links: Links[]
|
|
13
|
-
}
|
|
14
|
-
@customElement("sgds-footer")
|
|
15
|
-
export class SgdsFooter extends SgdsElement {
|
|
16
|
-
static styles = styles
|
|
17
|
-
@property()
|
|
18
|
-
title = ``;
|
|
19
|
-
@property()
|
|
20
|
-
description = ``;
|
|
21
|
-
@property({
|
|
22
|
-
type: Array,
|
|
23
|
-
})
|
|
24
|
-
links: ColumnLinks[] = [];
|
|
25
|
-
|
|
26
|
-
@property({ type: String })
|
|
27
|
-
lastUpdatedDate = "";
|
|
28
|
-
|
|
29
|
-
//href
|
|
30
|
-
@property({ type: String })
|
|
31
|
-
contactHref = "#";
|
|
32
|
-
@property({ type: String })
|
|
33
|
-
feedbackHref = "#";
|
|
34
|
-
@property({ type: String })
|
|
35
|
-
vulnerabilityHref = "#";
|
|
36
|
-
@property({ type: String })
|
|
37
|
-
privacyHref = "#";
|
|
38
|
-
@property({ type: String })
|
|
39
|
-
termsOfUseHref = "#";
|
|
40
|
-
|
|
41
|
-
render() {
|
|
42
|
-
return html`
|
|
43
|
-
<footer class="sgds footer">
|
|
44
|
-
<section class="footer-top" part="footer-top">
|
|
45
|
-
<div class="container-fluid">
|
|
46
|
-
<div class="row footer-header">
|
|
47
|
-
<div class="col col-lg-6 col-md-12">
|
|
48
|
-
<div class="title">${this.title}</div>
|
|
49
|
-
<div class="description">${this.description}</div>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
<div class="row footer-items">
|
|
53
|
-
${this.links.map(
|
|
54
|
-
(item: ColumnLinks) =>
|
|
55
|
-
html`
|
|
56
|
-
<div class="col-xxl-2 col-md-4 mb-3">
|
|
57
|
-
<div class="title">${item.title}</div>
|
|
58
|
-
<ul class="links">
|
|
59
|
-
${item.links.map(
|
|
60
|
-
(link: Links) =>
|
|
61
|
-
html`
|
|
62
|
-
<li><a href="${link.href}">${link.label}</a></li>
|
|
63
|
-
`
|
|
64
|
-
)}
|
|
65
|
-
</ul>
|
|
66
|
-
</div>
|
|
67
|
-
`
|
|
68
|
-
)}
|
|
69
|
-
</div>
|
|
70
|
-
<div class="row footer-contact-links">
|
|
71
|
-
<div class="col">
|
|
72
|
-
<div class="d-flex justify-content-lg-end">
|
|
73
|
-
<ul>
|
|
74
|
-
<li><a href="${this.contactHref}">Contact</a></li>
|
|
75
|
-
<li><a href="${this.feedbackHref}">Feedback</a></li>
|
|
76
|
-
<li>
|
|
77
|
-
<a
|
|
78
|
-
href="https://www.reach.gov.sg/"
|
|
79
|
-
target="_blank"
|
|
80
|
-
rel="noopener noreferrer"
|
|
81
|
-
>Reach.gov.sg</a>
|
|
82
|
-
</li>
|
|
83
|
-
</ul>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
</section>
|
|
89
|
-
<section class="footer-bottom" part="footer-bottom">
|
|
90
|
-
<div class="container-fluid">
|
|
91
|
-
<div class="row footer-mandatory-links">
|
|
92
|
-
<div class="col">
|
|
93
|
-
<ul>
|
|
94
|
-
<li>
|
|
95
|
-
<a
|
|
96
|
-
href="${this.vulnerabilityHref}"
|
|
97
|
-
target="_blank"
|
|
98
|
-
rel="noopener noreferrer"
|
|
99
|
-
>Report Vulnerability</a>
|
|
100
|
-
</li>
|
|
101
|
-
<li><a href="${this.privacyHref}">Privacy Statement</a></li>
|
|
102
|
-
<li><a href="${this.termsOfUseHref}">Terms of use</a></li>
|
|
103
|
-
</ul>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
<div class="row footer-copyrights">
|
|
107
|
-
<div class="col">
|
|
108
|
-
<div class="d-flex justify-content-lg-end text-end">
|
|
109
|
-
© ${new Date().getFullYear()} Government of Singapore<br />
|
|
110
|
-
Last Updated ${this.lastUpdatedDate}
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
</section>
|
|
116
|
-
</footer>
|
|
117
|
-
`;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export default SgdsFooter;
|
package/src/Input/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SgdsInput } from "./sgds-input";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
@import '../utils/base.scss';
|
|
3
|
-
@import "~@govtechsg/sgds/sass/forms/labels";
|
|
4
|
-
@import "~@govtechsg/sgds/sass/forms/form-text";
|
|
5
|
-
@import "~@govtechsg/sgds/sass/forms/form-control";
|
|
6
|
-
@import "~@govtechsg/sgds/sass/forms/form-control-group";
|
|
7
|
-
@import "~@govtechsg/sgds/sass/forms/input-group";
|
|
8
|
-
@import "~@govtechsg/sgds/sass/forms/validation";
|
|
9
|
-
|
|
10
|
-
:host{
|
|
11
|
-
--sgds-body-line-height: 2rem;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.form{
|
|
15
|
-
&-label,
|
|
16
|
-
&-text
|
|
17
|
-
{
|
|
18
|
-
line-height: var(--sgds-body-line-height);
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/Input/sgds-input.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { customElement, property,query, state } from "lit/decorators.js";
|
|
3
|
-
import { html } from 'lit/static-html.js';
|
|
4
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
-
import {classMap} from 'lit/directives/class-map.js';
|
|
6
|
-
import { live } from 'lit/directives/live.js';
|
|
7
|
-
import styles from "./sgds-input.scss";
|
|
8
|
-
import SgdsElement from "../utils/sgds-element";
|
|
9
|
-
import { defaultValue } from "../utils/defaultvalue";
|
|
10
|
-
import { FormSubmitController } from "../utils/form";
|
|
11
|
-
import genId from "../utils/generateId";
|
|
12
|
-
import { watch } from "../utils/watch";
|
|
13
|
-
@customElement("sgds-input")
|
|
14
|
-
export class SgdsInput extends SgdsElement {
|
|
15
|
-
@query('input.form-control') input: HTMLInputElement;
|
|
16
|
-
|
|
17
|
-
@state() private hasFocus = false;
|
|
18
|
-
|
|
19
|
-
private readonly formSubmitController = new FormSubmitController(this);
|
|
20
|
-
|
|
21
|
-
static styles = styles;
|
|
22
|
-
@property({ reflect: true }) type:
|
|
23
|
-
| 'date'
|
|
24
|
-
| 'datetime-local'
|
|
25
|
-
| 'email'
|
|
26
|
-
| 'number'
|
|
27
|
-
| 'password'
|
|
28
|
-
| 'search'
|
|
29
|
-
| 'tel'
|
|
30
|
-
| 'text'
|
|
31
|
-
| 'time'
|
|
32
|
-
| 'url' = 'text';
|
|
33
|
-
@property({ reflect: true }) label : string;
|
|
34
|
-
@property({ reflect: true}) hintText : string;
|
|
35
|
-
@property({ type:String, reflect: true }) inputId = genId("input", this.type);
|
|
36
|
-
@property({ reflect: true }) name : string;
|
|
37
|
-
@property({ reflect: true }) inputClasses : string;
|
|
38
|
-
@property({ reflect: true }) iconName: string;
|
|
39
|
-
|
|
40
|
-
@property({ type: String, reflect: true }) value = '';
|
|
41
|
-
@property({ type: String, reflect: true}) minlength;
|
|
42
|
-
@property({ type: String, reflect: true}) maxlength;
|
|
43
|
-
|
|
44
|
-
@property({ type: String, reflect: true }) placeholder = "Placeholder";
|
|
45
|
-
|
|
46
|
-
@property({ type: String }) pattern;
|
|
47
|
-
@property({ type: String, reflect: true }) invalidFeedback = "default feedback";
|
|
48
|
-
|
|
49
|
-
@property({ type: Boolean, reflect: true }) autofocus = false;
|
|
50
|
-
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
51
|
-
@property({ type: Boolean, reflect: true }) required = false;
|
|
52
|
-
/** Makes the input readonly. */
|
|
53
|
-
@property({ type: Boolean, reflect: true }) readonly = false;
|
|
54
|
-
|
|
55
|
-
@property({ type: Boolean, reflect: true }) invalid = false;
|
|
56
|
-
@property({ type: Boolean, reflect: true }) valid = false;
|
|
57
|
-
|
|
58
|
-
/** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
|
|
59
|
-
@defaultValue()
|
|
60
|
-
defaultValue = '';
|
|
61
|
-
|
|
62
|
-
/** Sets focus on the input. */
|
|
63
|
-
focus(options?: FocusOptions) {
|
|
64
|
-
this.input.focus(options);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
68
|
-
reportValidity() {
|
|
69
|
-
return this.input.reportValidity();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
handleInvalid() {
|
|
73
|
-
this.invalid = true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
handleChange(event: string){
|
|
77
|
-
this.value = this.input.value;
|
|
78
|
-
this.emit(event);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
handleFocus() {
|
|
82
|
-
this.hasFocus = true;
|
|
83
|
-
this.emit('sgds-focus');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
handleBlur() {
|
|
87
|
-
this.hasFocus = false;
|
|
88
|
-
this.emit('sgds-blur');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
handleKeyDown(event: KeyboardEvent) {
|
|
92
|
-
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
93
|
-
|
|
94
|
-
// Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before
|
|
95
|
-
// submitting to allow users to cancel the keydown event if they need to
|
|
96
|
-
if (event.key === 'Enter' && !hasModifier) {
|
|
97
|
-
setTimeout(() => {
|
|
98
|
-
if (!event.defaultPrevented) {
|
|
99
|
-
this.formSubmitController.submit();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@watch('disabled', { waitUntilFirstUpdate: true })
|
|
106
|
-
handleDisabledChange() {
|
|
107
|
-
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
108
|
-
this.input.disabled = this.disabled;
|
|
109
|
-
this.invalid = !this.input.checkValidity();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
@watch('value', { waitUntilFirstUpdate: true })
|
|
113
|
-
handleValueChange() {
|
|
114
|
-
this.invalid = !this.input.checkValidity();
|
|
115
|
-
this.valid = this.input.checkValidity()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
render() {
|
|
119
|
-
const input = html`
|
|
120
|
-
<input type="text"
|
|
121
|
-
class="form-control
|
|
122
|
-
${classMap(
|
|
123
|
-
{
|
|
124
|
-
'is-invalid' : this.invalid,
|
|
125
|
-
'is-valid' : this.valid,
|
|
126
|
-
[`${this.inputClasses}`]: this.inputClasses
|
|
127
|
-
})}
|
|
128
|
-
"
|
|
129
|
-
type=${this.type}
|
|
130
|
-
id=${this.inputId}
|
|
131
|
-
name=${ifDefined(this.name)}
|
|
132
|
-
placeholder=${ifDefined(this.placeholder)}
|
|
133
|
-
aria-invalid=${this.invalid ? 'true' : 'false'}
|
|
134
|
-
pattern=${ifDefined(this.pattern)}
|
|
135
|
-
?autofocus=${this.autofocus}
|
|
136
|
-
?disabled=${this.disabled}
|
|
137
|
-
?readonly=${this.readonly}
|
|
138
|
-
?required=${this.required}
|
|
139
|
-
.value=${live(this.value)}
|
|
140
|
-
minlength=${ifDefined(this.minlength)}
|
|
141
|
-
maxlength=${ifDefined(this.maxlength)}
|
|
142
|
-
@input=${()=> this.handleChange('sgds-input')}
|
|
143
|
-
@change=${()=> this.handleChange('sgds-change')}
|
|
144
|
-
@keydown=${this.handleKeyDown}
|
|
145
|
-
@invalid=${this.handleInvalid}
|
|
146
|
-
@focus=${this.handleFocus}
|
|
147
|
-
@blur=${this.handleBlur}
|
|
148
|
-
>
|
|
149
|
-
<div id="${this.inputId}-invalid" class="invalid-feedback">${this.invalidFeedback}</div>
|
|
150
|
-
`
|
|
151
|
-
// if iconName is defined
|
|
152
|
-
const inputWithIcon = html`
|
|
153
|
-
<div class="sgds form-control-group ${this.inputClasses}">
|
|
154
|
-
<span class="form-control-icon">
|
|
155
|
-
<sl-icon name=${this.iconName}></sl-icon>
|
|
156
|
-
</span>
|
|
157
|
-
${input}
|
|
158
|
-
</div>
|
|
159
|
-
`
|
|
160
|
-
// if hintText is defined
|
|
161
|
-
const withHintText = html`
|
|
162
|
-
<small id="${ifDefined(this.inputId)}Help" class="text-muted form-text">${this.hintText}</small>
|
|
163
|
-
`
|
|
164
|
-
|
|
165
|
-
// if label is defined
|
|
166
|
-
const withLabel = html`
|
|
167
|
-
<label for=${ifDefined(this.inputId)} class="form-label">${this.label}</label>
|
|
168
|
-
`
|
|
169
|
-
|
|
170
|
-
return html`
|
|
171
|
-
${this.label ? withLabel : undefined }
|
|
172
|
-
${this.hintText ? withHintText : undefined }
|
|
173
|
-
${this.iconName ? inputWithIcon : input}
|
|
174
|
-
`;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export default SgdsInput;
|
package/src/Mainnav/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
@import "./sgds-mainnav-item.scss";
|
|
2
|
-
@import "../Dropdown/sgds-dropdown.scss";
|
|
3
|
-
|
|
4
|
-
.nav-link {
|
|
5
|
-
gap: 1rem;
|
|
6
|
-
}
|
|
7
|
-
.dropdown-menu {
|
|
8
|
-
margin-top: 0;
|
|
9
|
-
border: 1px solid rgba($black, .1);
|
|
10
|
-
border-radius: 0 0 5px 5px;
|
|
11
|
-
background-color: $white;
|
|
12
|
-
box-shadow: 0 .5rem 1rem rgba($black, .15);
|
|
13
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { customElement} from "lit/decorators.js";
|
|
3
|
-
import { ref } from "lit/directives/ref.js";
|
|
4
|
-
import styles from "./sgds-mainnav-dropdown.scss";
|
|
5
|
-
import { DropdownElement } from "../utils/dropdown-element";
|
|
6
|
-
|
|
7
|
-
@customElement("sgds-mainnav-dropdown")
|
|
8
|
-
export class SgdsMainnavDropdown extends DropdownElement {
|
|
9
|
-
static styles = styles;
|
|
10
|
-
|
|
11
|
-
render() {
|
|
12
|
-
return html`
|
|
13
|
-
<li class="nav-item">
|
|
14
|
-
<a
|
|
15
|
-
class="nav-link"
|
|
16
|
-
?disabled=${this.disabled}
|
|
17
|
-
aria-expanded="${this.menuIsOpen}"
|
|
18
|
-
${ref(this.myDropdown)}
|
|
19
|
-
@click=${() => this._onClickButton()}
|
|
20
|
-
id=${this.togglerId}
|
|
21
|
-
tabindex=${this.disabled ? '-1' : '0'}
|
|
22
|
-
role="button"
|
|
23
|
-
>
|
|
24
|
-
${this.togglerText}
|
|
25
|
-
<svg
|
|
26
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
-
width="16"
|
|
28
|
-
height="16"
|
|
29
|
-
fill="currentColor"
|
|
30
|
-
class="bi bi-chevron-down"
|
|
31
|
-
viewBox="0 0 16 16"
|
|
32
|
-
>
|
|
33
|
-
<path
|
|
34
|
-
fill-rule="evenodd"
|
|
35
|
-
d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"
|
|
36
|
-
/>
|
|
37
|
-
</svg>
|
|
38
|
-
</a>
|
|
39
|
-
<ul class="dropdown-menu" role="menu" part="menu">
|
|
40
|
-
<slot @click=${this._handleSelectSlot}></slot>
|
|
41
|
-
</ul>
|
|
42
|
-
</li>
|
|
43
|
-
`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
@import "../utils/base.scss";
|
|
2
|
-
@import "~@govtechsg/sgds/sass/navbar";
|
|
3
|
-
|
|
4
|
-
:host {
|
|
5
|
-
--mainnav-item-theme-color: #5925DC;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
li {
|
|
9
|
-
height: 100%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
a.nav-link {
|
|
13
|
-
display: flex;
|
|
14
|
-
color: #344054;
|
|
15
|
-
border-bottom: $navbar-border-bottom-height solid transparent;
|
|
16
|
-
min-height: 100%;
|
|
17
|
-
align-items: center;
|
|
18
|
-
|
|
19
|
-
&.active,
|
|
20
|
-
&:hover {
|
|
21
|
-
color: var(--mainnav-item-theme-color);
|
|
22
|
-
border-color: var(--mainnav-item-theme-color);
|
|
23
|
-
}
|
|
24
|
-
}
|