|
1 | 1 | <script lang="ts"> |
2 | 2 |
|
3 | 3 | import type { NeoNotificationStackProps } from '~/floating/notification/neo-notification-stack.model'; |
| 4 | + import type { NeoNotification } from '~/floating/notification/neo-notification.model'; |
4 | 5 |
|
5 | 6 | import NeoButton from '~/buttons/NeoButton.svelte'; |
6 | 7 | import NeoButtonGroup from '~/buttons/NeoButtonGroup.svelte'; |
7 | 8 | import { NeoNotificationPlacements } from '~/floating/common/neo-placement.model.js'; |
8 | 9 | import NeoNotificationStack from '~/floating/notification/NeoNotificationStack.svelte'; |
9 | 10 | import NeoNumberStep from '~/inputs/NeoNumberStep.svelte'; |
10 | 11 | import NeoSelect from '~/inputs/NeoSelect.svelte'; |
11 | | - import { DefaultShadowElevation, MaxShadowElevation } from '~/utils/shadow.utils'; |
| 12 | + import { MaxShadowElevation } from '~/utils/shadow.utils'; |
12 | 13 |
|
13 | 14 | import { colorOptions } from '../utils/color.utils'; |
14 | 15 | import { positionOptions } from '../utils/placement.utils'; |
|
17 | 18 |
|
18 | 19 | const container = $state<NeoNotificationStackProps>({ |
19 | 20 | placement: NeoNotificationPlacements.TopEnd, |
20 | | - duration: 0, |
| 21 | + duration: 5000, |
21 | 22 | expand: false, |
22 | | - }); |
23 | | -
|
24 | | - const options = $state({ |
25 | | - elevation: DefaultShadowElevation, |
| 23 | + draggable: true, |
| 24 | + swipeable: true, |
| 25 | + close: true, |
| 26 | + loading: false, |
| 27 | + elevation: 1, |
26 | 28 | color: '', |
| 29 | + filled: false, |
| 30 | + tinted: false, |
| 31 | + rounded: false, |
| 32 | + borderless: false, |
27 | 33 | }); |
28 | | -
|
29 | 34 | let stack = $state<NeoNotificationStack>(); |
30 | 35 |
|
31 | | - const pushNotification = () => { |
| 36 | + const pushNotification = (notif?: NeoNotification) => { |
32 | 37 | if (!stack) return; |
33 | 38 | (window as any).stack = (window as any).stack || []; |
34 | 39 | (window as any).stack.push(stack.add({ |
35 | | - containerProps: { style: `height: ${5}rem; width: ${20}rem` }, |
36 | | - }), |
37 | | - ); |
| 40 | + title: `Item: ${new Date().toLocaleTimeString()}`, |
| 41 | + subtitle: 'Subtitle: this is a notification item', |
| 42 | + content: `This is a notification item created at ${new Date().toLocaleTimeString()}. |
| 43 | + You can customize it with various properties.`, |
| 44 | + ...notif, |
| 45 | + })); |
38 | 46 | }; |
39 | 47 |
|
40 | 48 | </script> |
|
46 | 54 | center |
47 | 55 | bind:value={container.duration} |
48 | 56 | min={0} |
49 | | - max={10000} |
| 57 | + max={60000} |
50 | 58 | defaultValue={0} |
51 | 59 | step={1000} |
52 | 60 | nullable={false} |
|
69 | 77 | rounded |
70 | 78 | glass |
71 | 79 | /> |
| 80 | +</div> |
| 81 | + |
| 82 | +<div class="row"> |
72 | 83 | <NeoNumberStep |
73 | 84 | label="Elevation" |
74 | 85 | placement="left" |
75 | 86 | center |
76 | | - bind:value={options.elevation} |
| 87 | + bind:value={container.elevation} |
77 | 88 | min={0} |
78 | 89 | max={MaxShadowElevation} |
79 | | - defaultValue={DefaultShadowElevation} |
| 90 | + defaultValue={1} |
80 | 91 | nullable={false} |
81 | 92 | floating={false} |
82 | 93 | groupProps={{ style: 'margin-left: 6rem' }} |
|
89 | 100 | placeholder="Select color" |
90 | 101 | placement="left" |
91 | 102 | floating={false} |
92 | | - color={options.color} |
| 103 | + color={container.color} |
93 | 104 | size={10} |
94 | | - bind:value={options.color} |
| 105 | + bind:value={container.color} |
95 | 106 | containerProps={{ style: 'margin-left: 6rem' }} |
96 | 107 | options={colorOptions} |
97 | 108 | openOnFocus |
|
103 | 114 | <div class="row"> |
104 | 115 | <NeoButtonGroup text rounded> |
105 | 116 | <NeoButton toggle bind:checked={container.expand}>Expand</NeoButton> |
| 117 | + <NeoButton toggle bind:checked={container.draggable}>Draggable</NeoButton> |
| 118 | + <NeoButton toggle bind:checked={container.swipeable}>Swipeable</NeoButton> |
| 119 | + <NeoButton toggle bind:checked={container.close}>Close</NeoButton> |
| 120 | + <NeoButton toggle bind:checked={container.loading}>Loading</NeoButton> |
| 121 | + <NeoButton toggle bind:checked={container.tinted}>Tinted</NeoButton> |
| 122 | + <NeoButton toggle bind:checked={container.filled}>Filled</NeoButton> |
| 123 | + <NeoButton toggle bind:checked={container.rounded}>Rounded</NeoButton> |
106 | 124 | <NeoButton onclick={stack?.clear}>Clear</NeoButton> |
107 | 125 | </NeoButtonGroup> |
108 | 126 | </div> |
|
111 | 129 |
|
112 | 130 | <section> |
113 | 131 | <div class="row"> |
114 | | - <div class="column"> |
115 | | - <span class="label">Notification</span> |
| 132 | + <span class="label">Basic</span> |
116 | 133 |
|
117 | | - <NeoButton elevation="0" onclick={pushNotification}>Default</NeoButton> |
118 | | - </div> |
| 134 | + <NeoButton elevation="0" onclick={() => pushNotification()}>Default</NeoButton> |
| 135 | + <NeoButton elevation="0" onclick={() => pushNotification({ type: 'info' })}>Info</NeoButton> |
| 136 | + <NeoButton elevation="0" onclick={() => pushNotification({ type: 'warning' })}>Warning</NeoButton> |
| 137 | + <NeoButton elevation="0" onclick={() => pushNotification({ type: 'error' })}>Error</NeoButton> |
| 138 | + <NeoButton elevation="0" onclick={() => pushNotification({ type: 'success' })}>Success</NeoButton> |
| 139 | + </div> |
| 140 | + |
| 141 | + <div class="row"> |
| 142 | + <span class="label">Advanced</span> |
| 143 | + |
| 144 | + <NeoButton elevation="0" onclick={() => pushNotification({ title: undefined, subtitle: undefined })}>Compact</NeoButton> |
| 145 | + <NeoButton |
| 146 | + elevation="0" |
| 147 | + onclick={() => pushNotification({ actionProps: { |
| 148 | + label: 'Action', |
| 149 | + onclick: () => { |
| 150 | + return 'dismissed'; |
| 151 | + }, |
| 152 | + } })} |
| 153 | + > |
| 154 | + Action |
| 155 | + </NeoButton> |
| 156 | + <NeoButton |
| 157 | + elevation="0" |
| 158 | + onclick={() => pushNotification({ |
| 159 | + progress: true, |
| 160 | + pauseOnHover: false, |
| 161 | + })} |
| 162 | + > |
| 163 | + Progress |
| 164 | + </NeoButton> |
119 | 165 | </div> |
120 | 166 | </section> |
121 | 167 |
|
|
133 | 179 | word-break: break-all; |
134 | 180 | } |
135 | 181 |
|
136 | | - .column { |
137 | | - @include flex.column($center: true, $gap: var(--neo-gap-lg), $flex: 0 1 auto); |
138 | | - } |
139 | | -
|
140 | 182 | .row { |
141 | 183 | @include flex.row($center: true, $gap: var(--neo-gap-xl), $flex: 0 1 auto); |
142 | 184 |
|
|
0 commit comments