nve-designsystem 0.1.9 → 0.1.11

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.
@@ -0,0 +1,79 @@
1
+ # nve-dialog
2
+
3
+ En sl-dialog i NVE-forkledning.
4
+ Mer info: https://shoelace.style/components/dialog
5
+
6
+ Vil du ha ikon foran tittelen kan du angi navnet på ikonet som attributt "icon".
7
+ Skal det ikke være mulig å trykke utenfor for å lukke dialogen, sett på disableDialog attributt
8
+
9
+ ## Properties
10
+
11
+ | Property | Attribute | Type | Default | Description |
12
+ |---------------------|---------------------|---------------|---------|--------------------------------------------------|
13
+ | `dialog` | | `HTMLElement` | | |
14
+ | `dir` | | `string` | | |
15
+ | `disableBackground` | `disableBackground` | `boolean` | false | Hvis disableBacground er true, kan man ikke trykke utenfor dialogen for å lukke den. |
16
+ | `icon` | `icon` | `string` | "" | Ikonet som skal vises |
17
+ | `label` | | `string` | | The dialog's label as displayed in the header. You should always include a relevant label even when using<br />`no-header`, as it is required for proper accessibility. If you need to display HTML, use the `label` slot instead. |
18
+ | `lang` | | `string` | | |
19
+ | `modal` | | `Modal` | | Exposes the internal modal utility that controls focus trapping. To temporarily disable focus<br />trapping and allow third-party modals spawned from an active Shoelace modal, call `modal.activateExternal()` when<br />the third-party modal opens. Upon closing, call `modal.deactivateExternal()` to restore Shoelace's focus trapping. |
20
+ | `noHeader` | | `boolean` | | Disables the header. This will also remove the default close button, so please ensure you provide an easy,<br />accessible way for users to dismiss the dialog. |
21
+ | `open` | | `boolean` | | Indicates whether or not the dialog is open. You can toggle this attribute to show and hide the dialog, or you can<br />use the `show()` and `hide()` methods and this attribute will reflect the dialog's open state. |
22
+ | `overlay` | | `HTMLElement` | | |
23
+ | `panel` | | `HTMLElement` | | |
24
+
25
+ ## Methods
26
+
27
+ | Method | Type | Description |
28
+ |----------------------|--------------------------------------------------|--------------------------------------------------|
29
+ | `emit` | `{ <T extends "submit" \| "reset" \| "abort" \| "animationcancel" \| "animationend" \| "animationiteration" \| "animationstart" \| "auxclick" \| "beforeinput" \| "blur" \| "cancel" \| "canplay" \| ... 112 more ... \| "sl-start">(name: EventTypeDoesNotRequireDetail<...>, options?: SlEventInit<...> \| undefined): GetCustomEventType<...` | Emits a custom event with more convenient defaults. |
30
+ | `handleOpenChange` | `(): Promise<void>` | |
31
+ | `handleRequestClose` | `(event: any): void` | |
32
+ | `hide` | `(): Promise<void>` | Hides the dialog |
33
+ | `show` | `(): Promise<void>` | Shows the dialog. |
34
+ | `updateIcon` | `(): void` | |
35
+
36
+ ## Events
37
+
38
+ | Event | Type | Description |
39
+ |--------------------|--------------------------------------------------|--------------------------------------------------|
40
+ | `sl-after-hide` | | Emitted after the dialog closes and all animations are complete. |
41
+ | `sl-after-show` | | Emitted after the dialog opens and all animations are complete. |
42
+ | `sl-hide` | | Emitted when the dialog closes. |
43
+ | `sl-initial-focus` | | Emitted when the dialog opens and is ready to receive focus. Calling<br />`event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input. |
44
+ | `sl-request-close` | `{ source: 'close-button' \| 'keyboard' \| 'overlay' }` | Emitted when the user attempts to<br />close the dialog by clicking the close button, clicking the overlay, or pressing escape. Calling<br />`event.preventDefault()` will keep the dialog open. Avoid using this unless closing the dialog will result in<br />destructive behavior such as data loss. |
45
+ | `sl-show` | | Emitted when the dialog opens. |
46
+
47
+ ## Slots
48
+
49
+ | Name | Description |
50
+ |------------------|--------------------------------------------------|
51
+ | | The dialog's main content. |
52
+ | `body` | hovedinnholdet |
53
+ | `footer` | feltet i bunden hvor knappene er plassert |
54
+ | `header-actions` | Optional actions to add to the header. Works best with `<sl-icon-button>`. |
55
+ | `label` | teksten som skal vises i overskriften. Eller du kan bruke label-attributtet |
56
+
57
+ ## CSS Shadow Parts
58
+
59
+ | Part | Description |
60
+ |----------------------|--------------------------------------------------|
61
+ | `base` | The component's base wrapper. |
62
+ | `body` | The dialog's body. |
63
+ | `close-button` | The close button, an `<sl-icon-button>`. |
64
+ | `close-button__base` | The close button's exported `base` part. |
65
+ | `footer` | The dialog's footer. |
66
+ | `header` | The dialog's header. This element wraps the title and header actions. |
67
+ | `header-actions` | Optional actions to add to the header. Works best with `<sl-icon-button>`. |
68
+ | `overlay` | The overlay that covers the screen behind the dialog. |
69
+ | `panel` | The dialog's panel (where the dialog and its content are rendered). |
70
+ | `title` | The dialog's title. |
71
+
72
+ ## CSS Custom Properties
73
+
74
+ | Property | Description |
75
+ |--------------------|--------------------------------------------------|
76
+ | `--body-spacing` | The amount of padding to use for the body. |
77
+ | `--footer-spacing` | The amount of padding to use for the footer. |
78
+ | `--header-spacing` | The amount of padding to use for the header. |
79
+ | `--width` | The preferred width of the dialog. Note that the dialog will shrink to accommodate smaller screens. |
@@ -0,0 +1,27 @@
1
+ # nve-divider
2
+
3
+ En Shoelace-divider i NVE-forkledning.
4
+ Se https://shoelace.style/components/divider
5
+
6
+ ## Properties
7
+
8
+ | Property | Type | Description |
9
+ |------------|-----------|----------------------------------------------|
10
+ | `dir` | `string` | |
11
+ | `lang` | `string` | |
12
+ | `vertical` | `boolean` | Draws the divider in a vertical orientation. |
13
+
14
+ ## Methods
15
+
16
+ | Method | Type | Description |
17
+ |------------------------|--------------------------------------------------|--------------------------------------------------|
18
+ | `emit` | `{ <T extends "submit" \| "reset" \| "abort" \| "animationcancel" \| "animationend" \| "animationiteration" \| "animationstart" \| "auxclick" \| "beforeinput" \| "blur" \| "cancel" \| "canplay" \| ... 112 more ... \| "sl-start">(name: EventTypeDoesNotRequireDetail<...>, options?: SlEventInit<...> \| undefined): GetCustomEventType<...` | Emits a custom event with more convenient defaults. |
19
+ | `handleVerticalChange` | `(): void` | |
20
+
21
+ ## CSS Custom Properties
22
+
23
+ | Property | Description |
24
+ |-------------|-----------------------------|
25
+ | `--color` | The color of the divider. |
26
+ | `--spacing` | The spacing of the divider. |
27
+ | `--width` | The width of the divider. |
@@ -0,0 +1,65 @@
1
+ # nve-dropdown
2
+
3
+ En Shoelace-dropdown i NVE-forkledning.
4
+ Se https://shoelace.style/components/dropdown
5
+
6
+ ## Properties
7
+
8
+ | Property | Type | Description |
9
+ |---------------------|--------------------------------------------------|--------------------------------------------------|
10
+ | `containingElement` | `HTMLElement \| undefined` | The dropdown will close when the user interacts outside of this element (e.g. clicking). Useful for composing other<br />components that use a dropdown internally. |
11
+ | `dir` | `string` | |
12
+ | `disabled` | `boolean` | Disables the dropdown so the panel will not open. |
13
+ | `distance` | `number` | The distance in pixels from which to offset the panel away from its trigger. |
14
+ | `hoist` | `boolean` | Enable this option to prevent the panel from being clipped when the component is placed inside a container with<br />`overflow: auto\|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios. |
15
+ | `lang` | `string` | |
16
+ | `open` | `boolean` | Indicates whether or not the dropdown is open. You can toggle this attribute to show and hide the dropdown, or you<br />can use the `show()` and `hide()` methods and this attribute will reflect the dropdown's open state. |
17
+ | `panel` | `HTMLSlotElement` | |
18
+ | `placement` | `"top" \| "top-start" \| "top-end" \| "bottom" \| "bottom-start" \| "bottom-end" \| "right" \| "right-start" \| "right-end" \| "left" \| "left-start" \| "left-end"` | The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel<br />inside of the viewport. |
19
+ | `popup` | `SlPopup` | |
20
+ | `skidding` | `number` | The distance in pixels from which to offset the panel along its trigger. |
21
+ | `stayOpenOnSelect` | `boolean` | By default, the dropdown is closed when an item is selected. This attribute will keep it open instead. Useful for<br />dropdowns that allow for multiple interactions. |
22
+ | `trigger` | `HTMLSlotElement` | |
23
+
24
+ ## Methods
25
+
26
+ | Method | Type | Description |
27
+ |---------------------------|--------------------------------------------------|--------------------------------------------------|
28
+ | `addOpenListeners` | `(): void` | |
29
+ | `emit` | `{ <T extends "submit" \| "reset" \| "abort" \| "animationcancel" \| "animationend" \| "animationiteration" \| "animationstart" \| "auxclick" \| "beforeinput" \| "blur" \| "cancel" \| "canplay" \| ... 112 more ... \| "sl-start">(name: EventTypeDoesNotRequireDetail<...>, options?: SlEventInit<...> \| undefined): GetCustomEventType<...` | Emits a custom event with more convenient defaults. |
30
+ | `focusOnTrigger` | `(): void` | |
31
+ | `getMenu` | `(): NveMenu \| undefined` | |
32
+ | `handleOpenChange` | `(): Promise<void>` | |
33
+ | `handleTriggerClick` | `(): void` | |
34
+ | `handleTriggerKeyDown` | `(event: KeyboardEvent): Promise<void>` | |
35
+ | `handleTriggerKeyUp` | `(event: KeyboardEvent): void` | |
36
+ | `handleTriggerSlotChange` | `(): void` | |
37
+ | `hide` | `(): Promise<void>` | Hides the dropdown panel |
38
+ | `removeOpenListeners` | `(): void` | |
39
+ | `reposition` | `(): void` | Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu<br />is activated. |
40
+ | `show` | `(): Promise<void>` | Shows the dropdown panel. |
41
+ | `updateAccessibleTrigger` | `(): void` | |
42
+
43
+ ## Events
44
+
45
+ | Event | Description |
46
+ |-----------------|--------------------------------------------------|
47
+ | `sl-after-hide` | Emitted after the dropdown closes and all animations are complete. |
48
+ | `sl-after-show` | Emitted after the dropdown opens and all animations are complete. |
49
+ | `sl-hide` | Emitted when the dropdown closes. |
50
+ | `sl-show` | Emitted when the dropdown opens. |
51
+
52
+ ## Slots
53
+
54
+ | Name | Description |
55
+ |-----------|--------------------------------------------------|
56
+ | | The dropdown's main content. |
57
+ | `trigger` | The dropdown's trigger, usually a `<sl-button>` element. |
58
+
59
+ ## CSS Shadow Parts
60
+
61
+ | Part | Description |
62
+ |-----------|--------------------------------------------------|
63
+ | `base` | The component's base wrapper. |
64
+ | `panel` | The panel that gets shown when the dropdown is open. |
65
+ | `trigger` | The container that wraps the trigger. |
@@ -0,0 +1,59 @@
1
+ # nve-menu-item
2
+
3
+ En sl-menu-item i NVE-forkledning.
4
+ Mer info: https://shoelace.style/components/menu-item
5
+
6
+ ## Properties
7
+
8
+ | Property | Attribute | Type | Default | Description |
9
+ |-----------------|-----------------|--------------------------|---------|--------------------------------------------------|
10
+ | `category` | `category` | `boolean` | false | Gjør at teksten vises som en unclickable kategori |
11
+ | `checked` | | `boolean` | | Draws the item in a checked state. |
12
+ | `defaultSlot` | | `HTMLSlotElement` | | |
13
+ | `dir` | | `string` | | |
14
+ | `disabled` | | `boolean` | | Draws the menu item in a disabled state, preventing selection. |
15
+ | `dividerBottom` | `dividerBottom` | `boolean` | false | Setter en divider på bunnen av item. |
16
+ | `dividerTop` | `dividerTop` | `boolean` | false | Setter en divider på toppen av item. |
17
+ | `indent` | `indent` | `boolean` | false | Gjør at teksten blir indent og mindre dominant farge |
18
+ | `lang` | | `string` | | |
19
+ | `menuItem` | | `HTMLElement` | | |
20
+ | `subtext` | `subtext` | `string` | "" | Tekst som vises som subtext(undertekst). |
21
+ | `type` | | `"normal" \| "checkbox"` | | The type of menu item to render. To use `checked`, this value must be set to `checkbox`. |
22
+ | `value` | | `string` | | A unique value to store in the menu item. This can be used as a way to identify menu items when selected. |
23
+
24
+ ## Methods
25
+
26
+ | Method | Type | Description |
27
+ |------------------------|--------------------------------------------------|--------------------------------------------------|
28
+ | `emit` | `{ <T extends "submit" \| "reset" \| "abort" \| "animationcancel" \| "animationend" \| "animationiteration" \| "animationstart" \| "auxclick" \| "beforeinput" \| "blur" \| "cancel" \| "canplay" \| ... 112 more ... \| "sl-start">(name: EventTypeDoesNotRequireDetail<...>, options?: SlEventInit<...> \| undefined): GetCustomEventType<...` | Emits a custom event with more convenient defaults. |
29
+ | `getTextLabel` | `(): string` | Returns a text label based on the contents of the menu item's default slot. |
30
+ | `handleCheckedChange` | `(): void` | |
31
+ | `handleDisabledChange` | `(): void` | |
32
+ | `handleTypeChange` | `(): void` | |
33
+ | `isSubmenu` | `(): boolean` | |
34
+
35
+ ## Slots
36
+
37
+ | Name | Description |
38
+ |-----------|--------------------------------------------------|
39
+ | | The menu item's label. |
40
+ | `prefix` | Used to prepend an icon or similar element to the menu item. |
41
+ | `submenu` | Used to denote a nested menu. |
42
+ | `suffix` | Used to append an icon or similar element to the menu item. |
43
+
44
+ ## CSS Shadow Parts
45
+
46
+ | Part | Description |
47
+ |----------------|--------------------------------------------------|
48
+ | `base` | The component's base wrapper. |
49
+ | `checked-icon` | The checked icon, which is only visible when the menu item is checked. |
50
+ | `label` | The menu item label. |
51
+ | `prefix` | The prefix container. |
52
+ | `submenu-icon` | The submenu icon, visible only when the menu item has a submenu (not yet implemented). |
53
+ | `suffix` | The suffix container. |
54
+
55
+ ## CSS Custom Properties
56
+
57
+ | Property | Default | Description |
58
+ |--------------------|---------|--------------------------------------------------|
59
+ | `--submenu-offset` | "-2px" | The distance submenus shift to overlap the parent menu. |
@@ -0,0 +1,34 @@
1
+ # nve-menu
2
+
3
+ En sl-menu i NVE-forkledning.
4
+ Mer info: https://shoelace.style/components/menu
5
+
6
+
7
+ ## Properties
8
+
9
+ | Property | Type |
10
+ |---------------|-------------------|
11
+ | `defaultSlot` | `HTMLSlotElement` |
12
+ | `dir` | `string` |
13
+ | `lang` | `string` |
14
+
15
+ ## Methods
16
+
17
+ | Method | Type | Description |
18
+ |------------------|--------------------------------------------------|--------------------------------------------------|
19
+ | `emit` | `{ <T extends "submit" \| "reset" \| "abort" \| "animationcancel" \| "animationend" \| "animationiteration" \| "animationstart" \| "auxclick" \| "beforeinput" \| "blur" \| "cancel" \| "canplay" \| ... 112 more ... \| "sl-start">(name: EventTypeDoesNotRequireDetail<...>, options?: SlEventInit<...> \| undefined): GetCustomEventType<...` | Emits a custom event with more convenient defaults. |
20
+ | `getAllItems` | `(): SlMenuItem[]` | |
21
+ | `getCurrentItem` | `(): SlMenuItem \| undefined` | |
22
+ | `setCurrentItem` | `(item: SlMenuItem): void` | |
23
+
24
+ ## Events
25
+
26
+ | Event | Type | Description |
27
+ |-------------|------------------------|---------------------------------------|
28
+ | `sl-select` | `{ item: SlMenuItem }` | Emitted when a menu item is selected. |
29
+
30
+ ## Slots
31
+
32
+ | Name | Description |
33
+ |------|--------------------------------------------------|
34
+ | | The menu's content, including menu items, menu labels, and dividers. |
@@ -15,7 +15,7 @@ En sl-tooltip i NVE-uniform. TODO: Denne har ingen NVE-styling ennå.
15
15
  | `hoist` | `boolean` | Enable this option to prevent the tooltip from being clipped when the component is placed inside a container with<br />`overflow: auto\|hidden\|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all,<br />scenarios. |
16
16
  | `lang` | `string` | |
17
17
  | `open` | `boolean` | Indicates whether or not the tooltip is open. You can use this in lieu of the show/hide methods. |
18
- | `placement` | `"top" \| "top-start" \| "top-end" \| "right" \| "right-start" \| "right-end" \| "bottom" \| "bottom-start" \| "bottom-end" \| "left" \| "left-start" \| "left-end"` | The preferred placement of the tooltip. Note that the actual placement may vary as needed to keep the tooltip<br />inside of the viewport. |
18
+ | `placement` | `"top" \| "top-start" \| "top-end" \| "bottom" \| "bottom-start" \| "bottom-end" \| "right" \| "right-start" \| "right-end" \| "left" \| "left-start" \| "left-end"` | The preferred placement of the tooltip. Note that the actual placement may vary as needed to keep the tooltip<br />inside of the viewport. |
19
19
  | `popup` | `SlPopup` | |
20
20
  | `skidding` | `number` | The distance in pixels from which to offset the tooltip along its target. |
21
21
  | `trigger` | `string` | Controls how the tooltip is activated. Possible options include `click`, `hover`, `focus`, and `manual`. Multiple<br />options can be passed by separating them with a space. When manual is used, the tooltip must be activated<br />programmatically. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nve-designsystem",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -3,11 +3,19 @@ export * from './nve-alert/nve-alert';
3
3
  export * from './nve-button/nve-button';
4
4
  export * from './nve-checkbox-group/nve-checkbox-group';
5
5
  export * from './nve-checkbox/nve-checkbox';
6
+ export * from './nve-dialog/nve-dialog';
7
+ export * from './nve-divider/nve-divider';
8
+ export * from './nve-dropdown/nve-dropdown';
6
9
  export * from './nve-icon/nve-icon';
7
10
  export * from './nve-input/nve-input';
8
11
  export * from './nve-label/nve-label';
9
- export * from './nve-radio/nve-radio.component';
12
+ export * from './nve-menu-item/nve-menu-item';
13
+ export * from './nve-menu/nve-menu';
10
14
  export * from './nve-radio-button/nve-radio-button.component';
11
15
  export * from './nve-radio-group/nve-radio-group.component';
16
+ export * from './nve-radio/nve-radio.component';
12
17
  export * from './nve-spinner/nve-spinner';
13
18
  export * from './nve-tooltip/nve-tooltip';
19
+
20
+ import '../utils/systemLibraryCustomization';
21
+
@@ -0,0 +1,91 @@
1
+ import { html } from 'lit';
2
+
3
+ const table = html`
4
+ <hr />
5
+ <h3 id="nve-label">nve-dialog</h3>
6
+ <table class="demo">
7
+ <thead>
8
+ <tr>
9
+ <th></th>
10
+ <th></th>
11
+ <th></th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <tbody>
16
+ <tr>
17
+ <td>Basic</td>
18
+ <nve-dialog label="Dialog tittel" class="dialog-width">
19
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
20
+ <div slot="footer">
21
+ <nve-button variant="primary" onclick="document.querySelector('.dialog-width').hide()">Lukk</nve-button>
22
+ </div>
23
+ </nve-dialog>
24
+ <td>
25
+ <nve-button onclick="document.querySelector('.dialog-width').show()" class="open-dialog" variant="primary">Open Dialog</nve-button>
26
+ </td>
27
+ </tr>
28
+
29
+ <tr>
30
+ <td>Slett</td>
31
+ <nve-dialog icon="warning" label="Vil du slette dette påbegynte skjemaet?" class="dialog-width2">
32
+ Du kan ikke angre dette etter du har slettet skjemaet.
33
+ <div slot="footer">
34
+ <nve-button variant="primary" onclick="document.querySelector('.dialog-width2').hide()">Slett</nve-button>
35
+ <nve-button class="close" variant="neutral" onclick="document.querySelector('.dialog-width2').hide()">Avbryt</nve-button>
36
+ </div>
37
+ </nve-dialog>
38
+ <td>
39
+ <nve-button onclick="document.querySelector('.dialog-width2').show()" class="open-dialog" variant="primary">Open Dialog</nve-button>
40
+ </td>
41
+ </tr>
42
+
43
+ <tr>
44
+ <td>Informasjonskapsler (cookies)</td>
45
+ <nve-dialog icon="cookie" label="Informasjonskapsler (cookies)" class="dialog-width3">
46
+ Noregs vassdrags- og energidirektorat (NVE) er underlagt Olje- og energidepartementet og har ansvar for å forvalte vass- og energiressursane til landet. NVE varetek også dei statlege forvaltingsoppgåvene innanfor skredførebygging.
47
+ <div slot="footer">
48
+ <nve-button variant="primary" onclick="document.querySelector('.dialog-width3').hide()">Godta alle</nve-button>
49
+ <nve-button class="close" onclick="document.querySelector('.dialog-width3').hide()">Kun nødvendige</nve-button>
50
+ <nve-button variant="neutral" onclick="document.querySelector('.dialog-width3').hide()">Mine valg</nve-button>
51
+ </div>
52
+ </nve-dialog>
53
+ <td>
54
+ <nve-button onclick="document.querySelector('.dialog-width3').show()" class="open-dialog" variant="primary">Open Dialog</nve-button>
55
+ </td>
56
+ </tr>
57
+
58
+ <tr>
59
+ <td>Kommenter (custom slot)</td>
60
+ <nve-dialog icon="info" label="Kommenter" class="dialog-width4">
61
+ <p>Nve-Textarea er ikke laget ennå</p>
62
+ <textarea placeholder="Skriv inn din kommentar her..."></textarea>
63
+ <div slot="footer">
64
+ <nve-button variant="primary" onclick="document.querySelector('.dialog-width4').hide()">Send</nve-button>
65
+ <nve-button variant="neutral" onclick="document.querySelector('.dialog-width4').hide()">Avbryt</nve-button>
66
+ </div>
67
+ </nve-dialog>
68
+ <td>
69
+ <nve-button onclick="document.querySelector('.dialog-width4').show()" class="open-dialog" variant="primary">Open Dialog</nve-button>
70
+ </td>
71
+ </tr>
72
+
73
+ <tr>
74
+ <td>Disable background</td>
75
+ <nve-dialog disableBackground label="I denne kan du ikke trykke utenfor for å lukke" class="dialog-width5" style="--width: 30vw;">
76
+ Tilfeldig tekst.
77
+ <div slot="footer">
78
+ <nve-button variant="primary" onclick="document.querySelector('.dialog-width5').hide()">Slett</nve-button>
79
+ <nve-button class="close" variant="neutral" onclick="document.querySelector('.dialog-width5').hide()">Avbryt</nve-button>
80
+ </div>
81
+ </nve-dialog>
82
+ <td>
83
+ <nve-button onclick="document.querySelector('.dialog-width5').show()" class="open-dialog" variant="primary">Open Dialog</nve-button>
84
+ </td>
85
+ </tr>
86
+ </tbody>
87
+ </table>
88
+
89
+ `;
90
+
91
+ export default table;
@@ -0,0 +1,51 @@
1
+ import { css } from 'lit';
2
+
3
+ export default css`
4
+ :host {
5
+ --header-spacing: var(--spacing-x-large, 2rem);
6
+ --body-spacing: var(--spacing-x-large, 2rem);
7
+ --footer-spacing: var(--spacing-x-large, 2rem);
8
+ --width: 40.625rem;
9
+ }
10
+
11
+ :host::part(footer), ::slotted([slot="footer"]) {
12
+ display: flex;
13
+ text-align: left;
14
+ gap: 0.75rem;
15
+
16
+ }
17
+ :host::part(title), ::slotted([slot="title"]) {
18
+ display: flex;
19
+ align-items: center;
20
+ gap: 0.5rem;
21
+ position: relative;
22
+ color: var(--neutrals-foreground-primary, #00131C);
23
+ font: var(--header-small);
24
+ line-height: 130%;
25
+ padding: var(--spacing-x-large, 2rem);
26
+ }
27
+
28
+ :host::part(title)::before {
29
+ font-family: 'Material Symbols Outlined';
30
+ content: var(--title-icon);
31
+ }
32
+
33
+ .dialog__header-actions sl-icon-button, .dialog__header-actions ::slotted(sl-icon-button) {
34
+ color: var(--neutrals-foreground-primary, #00131C);
35
+ font-family: Source Sans Pro;
36
+ font-size: 1.3rem;
37
+ font-style: normal;
38
+ font-weight: bold;
39
+ }
40
+
41
+ :host::part(body), ::slotted([slot="body"]) {
42
+ color: var(--neutrals-foreground-primary, #00131C);
43
+ font: var(--body-medium-default);
44
+ line-height: 150%;
45
+ padding: 0 var(--spacing-x-large, 2rem) 0 var(--spacing-x-large, 2rem);
46
+ }
47
+
48
+ .dialog__overlay {
49
+ background-color: rgba(13, 13, 14, 0.40);
50
+ }
51
+ `;
@@ -0,0 +1,77 @@
1
+ import { SlDialog } from '@shoelace-style/shoelace';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import styles from './nve-dialog-styles';
4
+ /**
5
+ * En sl-dialog i NVE-forkledning.
6
+ * Mer info: https://shoelace.style/components/dialog
7
+ *
8
+ * Vil du ha ikon foran tittelen kan du angi navnet på ikonet som attributt "icon".
9
+ * Skal det ikke være mulig å trykke utenfor for å lukke dialogen, sett på disableDialog attributt
10
+ *
11
+ * @slot label - teksten som skal vises i overskriften. Eller du kan bruke label-attributtet
12
+ * @slot body - hovedinnholdet
13
+ * @slot footer - feltet i bunden hvor knappene er plassert
14
+ *
15
+ */
16
+ @customElement('nve-dialog')
17
+ export class NveDialog extends SlDialog {
18
+ /**
19
+ * Ikonet som skal vises
20
+ */
21
+ @property({ type: String, reflect: true }) icon = '';
22
+ /**
23
+ * Hvis disableBacground er true, kan man ikke trykke utenfor dialogen for å lukke den.
24
+ */
25
+ @property({ type: Boolean, reflect: true }) disableBackground = false;
26
+
27
+ constructor() {
28
+ super();
29
+ }
30
+
31
+ /**
32
+ *
33
+ * Stjålet fra shoelace eksempel. Hindrer at man lukker dialogen ved å trykke utenfor
34
+ */
35
+ handleRequestClose(event: any) {
36
+ if (this.disableBackground && event.detail.source === 'overlay') {
37
+ event.preventDefault();
38
+ }
39
+ }
40
+
41
+ updated(changedProperties: any) {
42
+ super.updated(changedProperties);
43
+ if(changedProperties.has('disableBackground')){
44
+ this.addEventListener('sl-request-close', this.handleRequestClose);
45
+ }
46
+ this.updateIcon();
47
+
48
+
49
+ }
50
+ /**
51
+ * Oppdaterer ikonet som vises i dialogens tittel.
52
+ * Metoden søker først etter tittel-elementet i komponentens skygge-DOM.
53
+ * Hvis tittel-elementet finnes og `icon`-egenskapen er satt, oppdateres
54
+ * tittel-elementets stil for å inkludere det angitte ikonet.
55
+ * Hvis `icon`-egenskapen ikke er satt, settes ikoninnholdet til 'none'
56
+ * for å unngå å skape unødvendig mellomrom i layouten.
57
+ */
58
+ updateIcon() {
59
+ const titleElement = this.shadowRoot?.querySelector('.dialog__title');
60
+ if (titleElement instanceof HTMLElement) {
61
+ const iconContent = this.icon ? `"${this.icon}"` : 'none';
62
+ titleElement.style.setProperty('--title-icon', iconContent);
63
+ }
64
+ }
65
+
66
+ static styles = [
67
+ SlDialog.styles,
68
+ styles
69
+ ];
70
+
71
+ }
72
+
73
+ declare global {
74
+ interface HTMLElementTagNameMap {
75
+ 'nve-dialog': NveDialog;
76
+ }
77
+ }
@@ -0,0 +1,32 @@
1
+ import { SlDivider } from '@shoelace-style/shoelace';
2
+ import { css } from 'lit';
3
+ import { customElement } from 'lit/decorators.js';
4
+
5
+ /**
6
+ * En Shoelace-divider i NVE-forkledning.
7
+ * Se https://shoelace.style/components/divider
8
+ */
9
+ @customElement('nve-divider')
10
+ export class NveDivider extends SlDivider {
11
+ constructor() {
12
+ super();
13
+ }
14
+ static styles = [
15
+ SlDivider.styles,
16
+ css`
17
+ :host {
18
+ --color: var(--neutrals-border-subtle);
19
+ --width: var(--border-width-strong, 2px);
20
+ --spacing: var(--spacing-xx-small, 0.25rem);
21
+
22
+ }
23
+
24
+ `,
25
+ ];
26
+ }
27
+
28
+ declare global {
29
+ interface HTMLElementTagNameMap {
30
+ 'nve-divider': NveDivider;
31
+ }
32
+ }
@@ -0,0 +1,27 @@
1
+ import { html } from 'lit';
2
+
3
+ /**
4
+ * Demonstrasjon av nve-dropdown
5
+ */
6
+ const table = html`
7
+ <hr />
8
+ <h3 id="nve-dropdown">nve-dropdown</h3>
9
+ <nve-dropdown>
10
+ <nve-button variant="primary" slot="trigger">
11
+ <nve-icon name="expand_more" slot="suffix"></nve-icon>
12
+ Dropdown</nve-button>
13
+ <nve-menu>
14
+ <nve-menu-item >Tekst</nve-menu-item>
15
+ <nve-menu-item subtext='Dette er en undertekst'>Tekstrrrrrrrrrr</nve-menu-item>
16
+ <nve-menu-item>
17
+ <nve-checkbox >Tekst</nve-checkbox>
18
+ </nve-menu-item>
19
+ <nve-divider></nve-divider>
20
+ <nve-menu-item>Tekst</nve-menu-item>
21
+ </nve-menu>
22
+ </nve-dropdown>
23
+
24
+
25
+ `;
26
+
27
+ export default table;
@@ -0,0 +1,8 @@
1
+ import { css } from 'lit';
2
+
3
+ /* Roterer chevron når dropdown åpner */
4
+ export default css`
5
+ :host([open]) {
6
+ --icon-rotation: rotate(180deg);
7
+ }
8
+ `;