poe-svelte-ui-lib 1.96.0 → 1.98.0

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 CHANGED
@@ -104,14 +104,14 @@ npm install poe-svelte-ui-lib
104
104
 
105
105
  Текст идёт в три ступени: основной `--font-color`, вторичный `--muted-color`, подсказки `--faint-color`. Все три проходят WCAG AA (не ниже 4,5:1) на любом фоне темы. Текст не делают полупрозрачным (`opacity`), для вторичного текста берут `--muted-color`. Мельче 11px подписи не делают.
106
106
 
107
- Цвета ролей взяты у Apple: красный, оранжевый, жёлтый, зелёный, голубой, синий, фиолетовый, розовый и серый. У каждого цвета четыре варианта:
107
+ Цвета ролей - ровная гамма в OKLCH: красный, оранжевый, жёлтый, зелёный, голубой, синий, фиолетовый, плюс серый и розовый. Тоны идут по кругу с близким шагом (27, 58, 98, 150, 225, 262, 310), поэтому соседние цвета, например оранжевый и жёлтый или голубой и синий, хорошо различаются. В палитрах (мастер-цвет, теги) порядок такой: серый, красный, оранжевый, жёлтый, зелёный, голубой, синий, фиолетовый. У каждого цвета четыре варианта:
108
108
 
109
109
  - `--*-color` - заливка. Текст на ней белый, а на оранжевой и жёлтой тёмный (`--on-orange`, `--on-yellow`). Компоненты берут его из `--on-accent`, классы `bg-orange` и `bg-yellow` подставляют его сами;
110
110
  - `--*-text` - цветной текст;
111
111
  - `--*-soft` - мягкий фон блока или строки;
112
- - `--*-mark` - чистый цвет Apple для полос, точек и индикаторов. Для текста он не годится, жёлтый и голубой на белом не читаются.
112
+ - `--*-mark` - самый яркий цвет гаммы для полос, точек, тегов и индикаторов. Для текста он не годится, жёлтый и голубой на белом не читаются.
113
113
 
114
- Акцентный цвет `--accent-color` - это синий Apple.
114
+ Акцентный цвет `--accent-color` - это синий из гаммы.
115
115
 
116
116
  Цветной текст пишут через `--red-text`, `--green-text`, `--orange-text` и так далее (классы `text-(--red-text)`), а не через `--red-color`. Заливки `--*-color` как текст плохо читаются: в тёмной теме они тёмные, а жёлтая и оранжевая слишком светлые на белом.
117
117
 
@@ -12,6 +12,7 @@
12
12
  componentClass = "",
13
13
  size = { width: 1, height: 1 },
14
14
  label = { name: "", class: "text-left", icon: null },
15
+ chevron = true,
15
16
  children,
16
17
  actions,
17
18
  image = "",
@@ -52,14 +53,16 @@
52
53
  <span class={twMerge(`min-w-0 truncate text-[14px] font-semibold`, label.class)}>{label?.name}</span>
53
54
  </div>
54
55
 
55
- <svg
56
- xmlns="http://www.w3.org/2000/svg"
57
- class="h-[14px] w-[14px] shrink-0 text-[color-mix(in_srgb,var(--accent-color)_35%,var(--font-color))] transition-transform duration-200"
58
- style="transform: rotate({isOpen ? 180 : 0}deg)"
59
- viewBox="0 0 24 24"
60
- >
61
- <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 9l6 6 6-6" />
62
- </svg>
56
+ {#if chevron}
57
+ <svg
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ class="h-[14px] w-[14px] shrink-0 text-[color-mix(in_srgb,var(--accent-color)_35%,var(--font-color))] transition-transform duration-200"
60
+ style="transform: rotate({isOpen ? 180 : 0}deg)"
61
+ viewBox="0 0 24 24"
62
+ >
63
+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 9l6 6 6-6" />
64
+ </svg>
65
+ {/if}
63
66
  </button>
64
67
  {#if actions}
65
68
  <div class="flex shrink-0 items-center gap-1 pr-3">{@render actions()}</div>
@@ -31,6 +31,7 @@
31
31
  | `label.name` | `string` | `""` | Заголовок |
32
32
  | `label.class` | `string` | `"text-left"` | Классы текста заголовка |
33
33
  | `label.icon` | `Component \| string \| null` | `null` | Иконка заголовка |
34
+ | `chevron` | `boolean` | `true` | Стрелка раскрытия в заголовке. Без неё блок сворачивается нажатием на заголовок |
34
35
  | `image` | `string` | `""` | Картинка фона содержимого |
35
36
  | `children` | `Snippet` | | Содержимое |
36
37
 
@@ -1,6 +1,7 @@
1
1
  <!-- $lib/Divider/Divider.svelte - волосяная линия вместо скруглённой полосы 2px. -->
2
2
  <script lang="ts">
3
3
  import { twMerge } from "tailwind-merge"
4
+ import { itemAccentStyle } from "../widgetAccent"
4
5
  import type { IDividerProps } from "../types"
5
6
 
6
7
  let { id = crypto.randomUUID(), wrapperClass = "", type = "line", width = 1, color = "", anchor = "center" }: IDividerProps = $props()
@@ -10,7 +11,7 @@
10
11
 
11
12
  <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`flex h-full w-full flex-col ${anchorClass[anchor]}`, wrapperClass)}>
12
13
  {#if type === "line"}
13
- <!-- Без bg-* класса берём --hairline-color; явный bg-* задаёт цвет через --bg-color -->
14
- <div class={twMerge("w-full", color)} style="height: {width}px; background: {color ? 'var(--bg-color)' : 'var(--hairline-color)'};"></div>
14
+ <!-- Без bg-* класса берём --hairline-color; явный bg-* - мастер-цвет, как у остальных компонентов -->
15
+ <div class={twMerge("w-full", color)} style="height: {width}px; {itemAccentStyle(color) ?? ''} background: {color ? 'var(--accent-color)' : 'var(--hairline-color)'};"></div>
15
16
  {/if}
16
17
  </div>
@@ -3,6 +3,7 @@
3
3
  import { T } from "../locales/i18n"
4
4
  import type { IInputProps } from "../types"
5
5
  import { twMerge } from "tailwind-merge"
6
+ import { widgetAccentStyle, itemAccentStyle } from "../widgetAccent"
6
7
  import InfoIcon from "../libIcons/InfoIcon.svelte"
7
8
  import Tooltip from "../Tooltip.svelte"
8
9
  import CopiedChip from "../CopiedChip.svelte"
@@ -71,20 +72,30 @@
71
72
  return Number(num.toFixed(5))
72
73
  }
73
74
 
75
+ /* Мастер-цвет поля (bg-* в componentClass): рамка и лёгкий фон цветом роли; сам класс bg-* в поле не передаётся, иначе он срезает фон */
76
+ const hasRole = $derived(!!itemAccentStyle(componentClass))
77
+ const fieldClass = $derived(
78
+ componentClass
79
+ .split(/\s+/)
80
+ .filter((cls) => !cls.startsWith("bg-"))
81
+ .join(" "),
82
+ )
83
+
74
84
  /* Единая база поля: высота 36, радиус 10, текст по левому краю. Правый отступ учитывает кнопки (глаз / копировать / счётчик). */
75
85
  const fieldBase = $derived(
76
86
  `w-full rounded-[10px] border bg-(--field-color) px-3 text-[14px] text-left leading-none
77
87
  transition-[border-color,box-shadow,background-color] duration-150 outline-none
78
88
  placeholder:text-(--faint-color)
79
89
  [&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden
80
- ${isValid ? "border-(--border-color) focus:border-(--accent-color) focus:shadow-(--focus-shadow-color)" : "border-(--red-color) focus:border-(--red-color) focus:shadow-[0_0_0_3px_color-mix(in_srgb,var(--red-color),transparent_80%)]"}
90
+ ${hasRole && !disabled && !readonly ? "bg-[color-mix(in_srgb,var(--accent-color)_7%,var(--field-color))]" : ""}
91
+ ${isValid ? `${hasRole ? "border-[color-mix(in_srgb,var(--accent-color)_55%,var(--border-color))]" : "border-(--border-color)"} focus:border-(--accent-color) focus:shadow-(--focus-shadow-color)` : "border-(--red-color) focus:border-(--red-color) focus:shadow-[0_0_0_3px_color-mix(in_srgb,var(--red-color),transparent_80%)]"}
81
92
  ${disabled ? "cursor-not-allowed border-(--hairline-color) bg-(--container-color) text-(--faint-color)" : ""}
82
93
  ${readonly && !disabled ? "bg-(--container-color) text-(--muted-color)" : ""}
83
94
  ${help?.info ? "pl-9" : ""}`,
84
95
  )
85
96
  </script>
86
97
 
87
- <div class={twMerge(`relative flex w-full flex-col gap-1 ${type === "text-area" ? "h-full" : ""}`, wrapperClass)}>
98
+ <div class={twMerge(`relative flex w-full flex-col gap-1 ${type === "text-area" ? "h-full" : ""}`, wrapperClass)} style={widgetAccentStyle(componentClass)}>
88
99
  {#if label.name}
89
100
  <!-- Метка слева, 12/600 - вместо центрированного h5 -->
90
101
  <span class={twMerge(`text-[12px] font-semibold text-(--muted-color)`, label.class)}>{label.name}</span>
@@ -94,7 +105,7 @@
94
105
  {#if type === "number"}
95
106
  <input
96
107
  bind:value
97
- class={twMerge(fieldBase, "h-8 pr-9", componentClass)}
108
+ class={twMerge(fieldBase, "h-8 pr-9", fieldClass)}
98
109
  id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
99
110
  {placeholder}
100
111
  {disabled}
@@ -111,7 +122,7 @@
111
122
  {:else if type !== "text-area"}
112
123
  <input
113
124
  bind:value
114
- class={twMerge(fieldBase, `h-8 ${help.copyButton || type === "password" ? "pr-9" : ""}`, componentClass)}
125
+ class={twMerge(fieldBase, `h-8 ${help.copyButton || type === "password" ? "pr-9" : ""}`, fieldClass)}
115
126
  id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
116
127
  {placeholder}
117
128
  {disabled}
@@ -125,7 +136,7 @@
125
136
  {:else}
126
137
  <textarea
127
138
  bind:value
128
- class={twMerge(fieldBase, `h-full min-h-20 resize-y py-2 leading-[1.5] ${help.copyButton ? "pr-9" : ""}`, componentClass)}
139
+ class={twMerge(fieldBase, `h-full min-h-20 resize-y py-2 leading-[1.5] ${help.copyButton ? "pr-9" : ""}`, fieldClass)}
129
140
  id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
130
141
  {disabled}
131
142
  {maxlength}
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { twMerge } from "tailwind-merge"
3
+ import { widgetAccentStyle } from "../widgetAccent"
3
4
  import type { IJoystickProps } from "../types"
4
5
 
5
6
  let {
@@ -123,14 +124,18 @@
123
124
  }
124
125
  </script>
125
126
 
126
- <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`bg-blue relative flex w-full flex-col items-center`, wrapperClass)}>
127
+ <div
128
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
129
+ class={twMerge(`bg-blue relative flex w-full flex-col items-center`, wrapperClass)}
130
+ style={widgetAccentStyle(twMerge("bg-blue", wrapperClass))}
131
+ >
127
132
  {#if label.name}
128
133
  <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
129
134
  {/if}
130
135
 
131
136
  {#if !readonly}
132
137
  <div class="flex w-1/2 items-center justify-center">
133
- <div class="relative z-10 flex size-40 min-h-40 min-w-40 items-center justify-center rounded-full bg-(--bg-color) shadow-(--elevation-2)">
138
+ <div class="relative z-10 flex size-40 min-h-40 min-w-40 items-center justify-center rounded-full bg-(--bg-color) text-(--on-accent) shadow-(--elevation-2)">
134
139
  <!-- Основные кнопки (оси pitch и yaw) -->
135
140
  <div class="absolute h-full w-full overflow-hidden rounded-full">
136
141
  {#each directions as direction, index}
@@ -176,7 +181,7 @@
176
181
  {/each}
177
182
  </div>
178
183
  <!-- Кнопка по центру -->
179
- <div class="z-20 flex size-20 items-center justify-center rounded-full bg-(--bg-color) shadow-(--elevation-2)">
184
+ <div class="z-20 flex size-20 items-center justify-center rounded-full bg-(--bg-color) text-(--on-accent) shadow-(--elevation-2)">
180
185
  <button
181
186
  class="flex size-18 cursor-pointer rounded-full p-2 origin-center active:scale-95
182
187
  [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
@@ -218,7 +223,7 @@
218
223
  <!-- Боковые кнопки (ось roll) -->
219
224
  {#if axes[2].name !== ""}
220
225
  <div
221
- class="absolute flex h-15 w-65 items-center justify-between rounded-full shadow-(--elevation-2)"
226
+ class="absolute flex h-15 w-65 items-center justify-between rounded-full text-(--on-accent) shadow-(--elevation-2)"
222
227
  style="background: color-mix(in srgb, var(--bg-color), var(--shadow-color) 10%)"
223
228
  >
224
229
  <button
@@ -284,13 +289,9 @@
284
289
  class={twMerge(`m-0 inline-block min-w-0 flex-1 cursor-pointer items-center px-2 py-1 font-semibold shadow-sm transition-all duration-300
285
290
  select-none hover:shadow-md
286
291
  ${
287
- option === sensitivity && sensitivity !== null
288
- ? "z-10 py-1 shadow-[0_0_10px_var(--shadow-color)] hover:shadow-[0_0_15px_var(--shadow-color)]"
289
- : ""
290
- }
291
- ${sensitivityOptions.length > 0 && index === 0 ? "rounded-l-2xl" : ""} ${
292
- index === sensitivityOptions.length - 1 ? "rounded-r-2xl" : ""
293
- } bg-(--back-color)`)}
292
+ option === sensitivity && sensitivity !== null ? "z-10 bg-(--bg-color) text-(--on-accent)" : "bg-(--back-color)"
293
+ }
294
+ ${sensitivityOptions.length > 0 && index === 0 ? "rounded-l-2xl" : ""} ${index === sensitivityOptions.length - 1 ? "rounded-r-2xl" : ""}`)}
294
295
  onclick={() => {
295
296
  sensitivity = option
296
297
  }}
@@ -16,6 +16,7 @@
16
16
  <script lang="ts">
17
17
  import { T } from "../locales/i18n"
18
18
  import { twMerge } from "tailwind-merge"
19
+ import { widgetAccentStyle } from "../widgetAccent"
19
20
  import type { IPeriodChartProps } from "../types"
20
21
 
21
22
  let {
@@ -76,7 +77,7 @@
76
77
  const labelStep = $derived(Math.ceil(values.length / 12) || 1)
77
78
  </script>
78
79
 
79
- <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge("relative flex w-full flex-col gap-3", wrapperClass)}>
80
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge("relative flex w-full flex-col gap-3", wrapperClass)} style={widgetAccentStyle(wrapperClass)}>
80
81
  {#if label.name}
81
82
  <h5 class={twMerge("w-full text-[13px] font-semibold text-(--muted-color)", label.class)}>{label.name}</h5>
82
83
  {/if}
@@ -1,6 +1,7 @@
1
1
  <!-- $lib/ProgressBar/ProgressBar.svelte - полоса 6px, подпись и значение над ней -->
2
2
  <script lang="ts">
3
3
  import { twMerge } from "tailwind-merge"
4
+ import { itemAccentStyle } from "../widgetAccent"
4
5
  import type { IProgressBarProps, IReceivingDataObject } from "../types"
5
6
 
6
7
  let {
@@ -66,13 +67,14 @@
66
67
  <div
67
68
  id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
68
69
  class={twMerge(`relative flex w-full ${type == "vertical" ? "h-full flex-wrap justify-center gap-6" : "flex-col gap-3"}`, wrapperClass)}
70
+ style={itemAccentStyle(wrapperClass)}
69
71
  >
70
72
  {#each items as progress, index}
71
73
  {#if type === "vertical"}
72
74
  <div class="flex h-full flex-col items-center gap-2">
73
75
  <span class="text-[12px] font-semibold text-(--muted-color)">{getItemName(index)}</span>
74
76
  <!-- Дорожка 6px, заливка снизу вверх -->
75
- <div class={twMerge("relative w-1.5 flex-1 overflow-hidden rounded-full bg-(--container-color)", progress.class)}>
77
+ <div class={twMerge("relative w-1.5 flex-1 overflow-hidden rounded-full bg-(--container-color)", progress.class)} style={itemAccentStyle(progress.class)}>
76
78
  <div class="absolute bottom-0 left-0 w-full bg-(--bg-color)" style="height: {progressPercent(getItemValue(index))}%;"></div>
77
79
  </div>
78
80
  <span class="text-[13px] font-semibold tabular-nums">{roundToClean(Number(numericValue(getItemValue(index))))}{number.units}</span>
@@ -86,7 +88,7 @@
86
88
  <span class="truncate text-[12px] font-semibold text-(--muted-color)">{getItemName(index)}</span>
87
89
  <span class="shrink-0 text-[12px] font-semibold tabular-nums">{roundToClean(Number(numericValue(getItemValue(index))))}{number.units}</span>
88
90
  </div>
89
- <div class={twMerge("relative h-1.5 w-full overflow-hidden rounded-full bg-(--container-color)", progress.class)}>
91
+ <div class={twMerge("relative h-1.5 w-full overflow-hidden rounded-full bg-(--container-color)", progress.class)} style={itemAccentStyle(progress.class)}>
90
92
  <div class="absolute top-0 left-0 h-full bg-(--bg-color)" style="width: {progressPercent(getItemValue(index))}%;"></div>
91
93
  </div>
92
94
  {#if getItemInfo(index)}
@@ -4,6 +4,7 @@
4
4
  import { onMount } from "svelte"
5
5
  import type { IOption, ISelectProps } from "../types"
6
6
  import { twMerge } from "tailwind-merge"
7
+ import { itemAccentStyle } from "../widgetAccent"
7
8
  import { T } from "../locales/i18n"
8
9
  import Tooltip from "../Tooltip.svelte"
9
10
 
@@ -220,8 +221,8 @@
220
221
  ${
221
222
  hasOwnColor
222
223
  ? selected
223
- ? 'ring-2 ring-inset ring-(--font-color)'
224
- : ''
224
+ ? 'text-(--on-accent) ring-2 ring-inset ring-(--font-color)'
225
+ : 'text-(--on-accent)'
225
226
  : selected
226
227
  ? 'text-(--on-accent)'
227
228
  : 'text-(--font-color) hover:bg-(--container-color)'
@@ -230,6 +231,7 @@
230
231
  ${fitContent ? 'px-3 whitespace-nowrap' : ''}`,
231
232
  option.class,
232
233
  )} {hasOwnColor ? 'bg-(--bg-color)' : selected ? 'bg-(--bg-color,var(--accent-color))' : 'bg-(--back-color)'}"
234
+ style={hasOwnColor ? itemAccentStyle(option.class) : undefined}
233
235
  onclick={(e) => selectOption(option, e)}
234
236
  disabled={option.disabled || disabled}
235
237
  aria-pressed={!!isSelected(option)}
@@ -3,6 +3,7 @@
3
3
  import { T } from "../locales/i18n"
4
4
  import type { ISliderProps } from "../types"
5
5
  import { twMerge } from "tailwind-merge"
6
+ import { widgetAccentStyle } from "../widgetAccent"
6
7
 
7
8
  let {
8
9
  id = crypto.randomUUID(),
@@ -30,6 +31,17 @@
30
31
  const span = Math.abs((number.maxNum ?? 10) - (number.minNum ?? 0)) || 1
31
32
  return Math.max(0, Math.min(100, ((v - (number.minNum ?? 0)) / span) * 100))
32
33
  }
34
+ /* Центр бегунка: он ходит не по всей ширине, а от 9px до ширины минус 9px (половина размера 18px), заливка считается так же */
35
+ const thumbX = (v: number) => `calc(9px + (100% - 18px) * ${pct(v) / 100})`
36
+
37
+ /* Значение на сетке шага: браузер ставит бегунок только на min + k * step, заливка должна стоять там же */
38
+ const snap = (v: number) => {
39
+ const min = number.minNum ?? 0
40
+ const max = number.maxNum ?? 10
41
+ const step = number.step || 1
42
+ const k = Math.round((v - min) / step)
43
+ return roundToClean(Math.max(min, Math.min(max, min + k * step)))
44
+ }
33
45
 
34
46
  $effect(() => {
35
47
  if (value === undefined || value === null) {
@@ -57,10 +69,10 @@
57
69
 
58
70
  $effect(() => {
59
71
  if (Array.isArray(value)) {
60
- lowerValue = roundToClean(value[0])
61
- upperValue = roundToClean(value[1])
72
+ lowerValue = snap(value[0])
73
+ upperValue = snap(value[1])
62
74
  } else if (typeof value === "number") {
63
- singleValue = roundToClean(value)
75
+ singleValue = snap(value)
64
76
  }
65
77
  })
66
78
 
@@ -88,7 +100,7 @@
88
100
  /* Двойной слайдер: оба input на всю ширину трека с ОДИНАКОВЫМ min/max, наложены друг на друга. pointer-events выключен на самом input и включён только на ::thumb (класс .range-overlay ниже) - тянуть можно исключительно за конкретный бегунок. Tailwind не генерирует CSS для сочетания произвольного варианта псевдоэлемента с pointer-events-*, поэтому это обычный style-блок ниже, а не класс. */
89
101
  </script>
90
102
 
91
- <div class={twMerge(`relative flex w-full flex-col gap-1.5`, wrapperClass)}>
103
+ <div class={twMerge(`relative flex w-full flex-col gap-1.5`, wrapperClass)} style={widgetAccentStyle(wrapperClass)}>
92
104
  {#if label.name}
93
105
  <h5 class={twMerge(`w-full text-[12px] font-semibold text-(--muted-color)`, label.class)}>{label.name}</h5>
94
106
  {/if}
@@ -102,12 +114,12 @@
102
114
  {#if isRange}
103
115
  <div
104
116
  class="pointer-events-none absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-(--bg-color,var(--accent-color))"
105
- style="left: {pct(lowerValue)}%; width: {Math.max(0, pct(upperValue) - pct(lowerValue))}%;"
117
+ style="left: {thumbX(lowerValue)}; width: calc({thumbX(upperValue)} - {thumbX(lowerValue)});"
106
118
  ></div>
107
119
  {:else}
108
120
  <div
109
121
  class="pointer-events-none absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-(--bg-color,var(--accent-color))"
110
- style="width: {pct(singleValue)}%;"
122
+ style="width: {thumbX(singleValue)};"
111
123
  ></div>
112
124
  {/if}
113
125
 
@@ -1,6 +1,7 @@
1
1
  <!-- $lib/Switch/Switch.svelte - тумблер, геометрия считается от пропа height; чекбокс 20px с радиусом 6 -->
2
2
  <script lang="ts">
3
3
  import { twMerge } from "tailwind-merge"
4
+ import { itemAccentStyle } from "../widgetAccent"
4
5
  import type { ISwitchProps } from "../types"
5
6
  import Tooltip from "../Tooltip.svelte"
6
7
 
@@ -56,14 +57,14 @@
56
57
  </script>
57
58
 
58
59
  {#if type !== "checkbox"}
59
- <div class={twMerge(`relative flex w-full flex-col items-center justify-center gap-1.5`, wrapperClass)}>
60
+ <div class={twMerge(`relative flex w-full flex-col items-center justify-center gap-1.5`, wrapperClass)} style={itemAccentStyle(wrapperClass)}>
60
61
  {#if label.name}
61
62
  <!-- Подпись по умолчанию по центру - над переключателем, который тоже по центру; выравнивание из label.class важнее -->
62
63
  <h5 class={twMerge(`w-full text-center text-[12px] font-semibold text-(--muted-color)`, label.class)}>{label.name}</h5>
63
64
  {/if}
64
65
  <div class="flex w-full {type == 'vertical' ? 'flex-wrap' : ''} items-center justify-around gap-4">
65
66
  {#each localOptions as option, index}
66
- <div class={twMerge(`flex flex-col gap-1`, option.class)}>
67
+ <div class={twMerge(`flex flex-col gap-1`, option.class)} style={itemAccentStyle(option.class)}>
67
68
  {#if option.name && bitMode}
68
69
  <span class="text-center text-[12px] font-medium text-(--muted-color)">{option.name}</span>
69
70
  {/if}
@@ -132,6 +133,7 @@
132
133
  wrapperClass,
133
134
  options[0]?.class?.split(" ").find((cl) => cl.startsWith("bg-")),
134
135
  )}
136
+ style={itemAccentStyle(options[0]?.class) ?? itemAccentStyle(wrapperClass)}
135
137
  >
136
138
  <input
137
139
  id={ID}
@@ -145,7 +147,7 @@
145
147
  checked:after:absolute checked:after:top-[1px] checked:after:left-[6px]
146
148
  checked:after:h-[10px] checked:after:w-[5px] checked:after:rotate-45
147
149
  checked:after:border-2 checked:after:border-t-0 checked:after:border-l-0
148
- checked:after:border-solid checked:after:border-white checked:after:opacity-100
150
+ checked:after:border-solid checked:after:border-(--on-accent) checked:after:opacity-100
149
151
  checked:after:content-['']
150
152
  focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent-color)
151
153
  disabled:cursor-not-allowed disabled:border-(--hairline-color) disabled:bg-(--container-color)
@@ -3,6 +3,7 @@
3
3
  import type { IOption, ITableButton, ITableContent, ITableHeader, ITableImage, ITableProgressBar, ITableProps, ITableText } from "../types"
4
4
  import { fly, slide } from "svelte/transition"
5
5
  import { twMerge } from "tailwind-merge"
6
+ import { widgetAccentStyle } from "../widgetAccent"
6
7
  import { onMount, tick } from "svelte"
7
8
  import ButtonClear from "../libIcons/ButtonClear.svelte"
8
9
  import { T } from "../locales/i18n"
@@ -255,7 +256,7 @@
255
256
  })
256
257
  </script>
257
258
 
258
- <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`flex h-full w-full flex-col overflow-hidden`, wrapperClass)}>
259
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`flex h-full w-full flex-col overflow-hidden`, wrapperClass)} style={widgetAccentStyle(wrapperClass)}>
259
260
  {#if label.name}
260
261
  <span class={twMerge(`w-full pb-2 text-[12px] font-semibold text-(--muted-color)`, label.class)}>{label.name}</span>
261
262
  {/if}
@@ -2,6 +2,7 @@
2
2
  <script lang="ts">
3
3
  import type { ITabsProps } from "../types"
4
4
  import { twMerge } from "tailwind-merge"
5
+ import { widgetAccentStyle } from "../widgetAccent"
5
6
 
6
7
  let {
7
8
  id = crypto.randomUUID(),
@@ -20,7 +21,7 @@
20
21
  const isCol = $derived(!!items.find((item) => item.class?.startsWith("flex-col")))
21
22
  </script>
22
23
 
23
- <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class="h-full w-full">
24
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class="h-full w-full" style={widgetAccentStyle(wrapperClass)}>
24
25
  <div class="flex h-full w-full flex-col overflow-hidden rounded-[14px] border border-(--hairline-color) bg-(--back-color)">
25
26
  <!-- Полоса вкладок - outer оставлен «чистым» скролл-контейнером без justify-*: justify-content на самом overflow-x-auto блоке при контенте чуть шире контейнера даёт паразитный горизонтальный скролл на пару px даже когда прокручивать нечего (классический баг центрирования flex-контейнера с overflow). Поэтому justify-* из wrapperClass уходит на внутреннюю обёртку, а не на сам скролл-контейнер. -->
26
27
  <div class="sticky top-0 z-40 flex h-fit items-center overflow-x-auto border-b border-(--hairline-color) px-4">
@@ -3,7 +3,7 @@
3
3
  import { T } from "../locales/i18n"
4
4
  import { findOptionByClass, updateProperty, type ITextFieldProps, type IUIComponentHandler, type UIComponent } from "../types"
5
5
  import * as UI from "../index"
6
- import { optionsStore, findColorOption } from "../options"
6
+ import { optionsStore, findColorOption, stripLegacyTextColor } from "../options"
7
7
  import { getContext } from "svelte"
8
8
  import { twMerge } from "tailwind-merge"
9
9
  import CommonSnippets from "../CommonSnippets.svelte"
@@ -49,7 +49,7 @@
49
49
  options={$optionsStore.TEXT_COLOR_OPTIONS}
50
50
  value={initialColor}
51
51
  onUpdate={(option) =>
52
- updateProperty("wrapperClass", twMerge(component.properties.wrapperClass, (option as UI.IOption).value as string), component, onPropertyChange)}
52
+ updateProperty("wrapperClass", twMerge(stripLegacyTextColor(component.properties.wrapperClass), (option as UI.IOption).value as string), component, onPropertyChange)}
53
53
  />
54
54
  {/snippet}
55
55
 
@@ -6,6 +6,7 @@
6
6
  import type { IOption, IVideoViewerProps } from "../types"
7
7
  import { onMount } from "svelte"
8
8
  import { twMerge } from "tailwind-merge"
9
+ import { widgetAccentStyle } from "../widgetAccent"
9
10
 
10
11
  let {
11
12
  id = crypto.randomUUID(),
@@ -22,7 +23,7 @@
22
23
  /* Мастер-цвет bg-* рисуется кольцом ring вокруг кадра: ring не меняет размеры контейнера, в отличие от border */
23
24
  const roleBorderClass = $derived.by(() => {
24
25
  const role = wrapperClass?.match(/bg-(\w+)/)?.[1]
25
- return role && role !== "max" ? `ring-2 ring-inset ring-(--border-color) border-${role}` : ""
26
+ return role && role !== "max" ? "ring-2 ring-inset ring-(--accent-color)" : ""
26
27
  })
27
28
 
28
29
  let videoElement = $state<HTMLVideoElement | null>(null)
@@ -141,7 +142,7 @@
141
142
  })
142
143
  </script>
143
144
 
144
- <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge("flex flex-col w-full h-full items-center", wrapperClass)}>
145
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge("flex flex-col w-full h-full items-center", wrapperClass)} style={widgetAccentStyle(wrapperClass ?? "")}>
145
146
  {#if label.name}
146
147
  <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
147
148
  {/if}
@@ -151,7 +152,7 @@
151
152
  {#if status !== "live" || !remoteImgSrc}
152
153
  <div class="absolute z-10 flex h-full w-full flex-col items-center justify-center gap-4 rounded-[14px] bg-(--container-color) p-4 text-center">
153
154
  {#if status === "error"}
154
- <svg class="w-12 h-12 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
155
+ <svg class="w-12 h-12 text-(--red-text)" fill="none" stroke="currentColor" viewBox="0 0 24 24">
155
156
  <path
156
157
  stroke-linecap="round"
157
158
  stroke-linejoin="round"
@@ -178,7 +179,7 @@
178
179
  {#if loading}
179
180
  <h2>{$T("constructor.props.camera.loading")}</h2>
180
181
  {:else if error}
181
- <svg class="w-12 h-12 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
182
+ <svg class="w-12 h-12 text-(--red-text)" fill="none" stroke="currentColor" viewBox="0 0 24 24">
182
183
  <path
183
184
  stroke-linecap="round"
184
185
  stroke-linejoin="round"
@@ -2,7 +2,7 @@
2
2
  import { T } from "../locales/i18n"
3
3
  import { updateProperty, type IUIComponentHandler, type UIComponent } from "../types"
4
4
  import * as UI from ".."
5
- import { optionsStore, findColorOption } from "../options"
5
+ import { optionsStore, findColorOption, stripLegacyTextColor } from "../options"
6
6
  import { ICONS_ARRAY } from "../icons"
7
7
  import { twMerge } from "tailwind-merge"
8
8
  import CommonSnippets from "../CommonSnippets.svelte"
@@ -38,7 +38,7 @@
38
38
  value={(initialColor?.value as string) ?? ""}
39
39
  onUpdate={(bgClass) => {
40
40
  updateProperty("settings.class", twMerge(component.properties.settings?.class, bgClass), component, onPropertyChange)
41
- updateProperty("icons.class", twMerge(component.properties.icons?.class, deriveIconColorClass(bgClass)), component, onPropertyChange)
41
+ updateProperty("icons.class", twMerge(stripLegacyTextColor(component.properties.icons?.class), deriveIconColorClass(bgClass)), component, onPropertyChange)
42
42
  }}
43
43
  />
44
44
  {/snippet}
@@ -1,5 +1,11 @@
1
1
  /* $lib/libIcons/propsIcons.ts - иконки вариантов панелей свойств (IOption.icon): контурные 24×24 в стиле остальных иконок библиотеки */
2
2
  const svg = (d) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
3
+ /* Иконка слайдера 44×20: fills - отрезки заливки [от, до], thumbs - центры бегунков по X */
4
+ const sliderIcon = (fills, thumbs) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 20" style="width:44px;height:20px" fill="currentColor" stroke="currentColor" stroke-linecap="round">` +
5
+ `<path d="M3 10h38" stroke-width="2.5" opacity="0.3"/>` +
6
+ fills.map(([a, b]) => `<path d="M${a} 10h${b - a}" stroke-width="3.5"/>`).join("") +
7
+ thumbs.map((x) => `<circle cx="${x}" cy="10" r="5.5" stroke="none"/>`).join("") +
8
+ `</svg>`;
3
9
  export const PROPS_ICONS = {
4
10
  /* Выравнивание текста и блока */
5
11
  alignLeft: svg("M15 12H3M17 18H3M21 6H3"),
@@ -27,8 +33,9 @@ export const PROPS_ICONS = {
27
33
  toggleVertical: svg("M5 8a7 7 0 0 1 14 0v8a7 7 0 0 1-14 0zm7-3a3 3 0 1 0 0 6 3 3 0 1 0 0-6z"),
28
34
  checkbox: svg("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm4 9 2 2 4-4"),
29
35
  /* Слайдер и разделитель */
30
- sliderSingle: svg("M3 12h2m6 0h10M8 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6z"),
31
- sliderRange: svg("M3 12h1m6 0h4m6 0h1M7 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6zm10 0a3 3 0 1 0 0 6 3 3 0 1 0 0-6z"),
36
+ /* Типы слайдера - маленький слайдер: бледная дорожка, заливка и бегунки; шире обычной иконки, чтобы было видно, где заливка */
37
+ sliderSingle: sliderIcon([[3, 24]], [24]),
38
+ sliderRange: sliderIcon([[14, 30]], [14, 30]),
32
39
  dividerLine: svg("M3 12h18"),
33
40
  dividerSpace: svg("M4 6v12M20 6v12M8 12h8"),
34
41
  /* Вписывание изображения */
package/dist/options.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export declare const findColorOption: <T extends {
2
2
  value: string;
3
3
  }>(options: T[], classString?: string, prefix?: string) => T | undefined;
4
+ export declare const stripLegacyTextColor: (classString?: string) => string;
4
5
  export declare const optionsStore: import("svelte/store").Readable<{
5
6
  HEADER_OPTIONS: {
6
7
  id: string;
package/dist/options.js CHANGED
@@ -5,11 +5,16 @@ import { PROPS_ICONS } from "./libIcons/propsIcons";
5
5
  function id() {
6
6
  return crypto.randomUUID();
7
7
  }
8
- /* Достаёт роль master-цвета (класс bg-*) из строки классов компонента и находит соответствующую запись в COLOR_OPTIONS - общий хелпер для всех *Props-панелей, где нужно предзаполнить пикер цвета. */
8
+ /* Находит в палитре (COLOR_OPTIONS, TEXT_COLOR_OPTIONS) вариант, класс которого есть в строке классов компонента - общий хелпер для *Props-панелей, где нужно предзаполнить пикер цвета */
9
9
  export const findColorOption = (options, classString, prefix = "bg-") => {
10
- const colorClass = classString?.split(" ").find((cls) => cls.startsWith(prefix));
11
- return colorClass ? options.find((c) => c.value.includes(colorClass)) : undefined;
10
+ const classes = (classString ?? "").split(/\s+/).filter((cls) => cls.startsWith(prefix));
11
+ return options.find((c) => classes.includes(c.value.split(" ")[0]));
12
12
  };
13
+ /* Убирает цвет текста старого формата (палитра Tailwind вида text-red-500 dark:text-red-400 и text-[#333]), чтобы новый цвет темы не перебивался в тёмной теме */
14
+ export const stripLegacyTextColor = (classString = "") => classString
15
+ .split(/\s+/)
16
+ .filter((cls) => !/^(dark:)?text-(red|yellow|green|blue|purple|gray)-\d{3}$/.test(cls) && !/^(dark:)?text-\[#(333|e2e3e7)\]$/.test(cls))
17
+ .join(" ");
13
18
  export const optionsStore = derived(T, ($T) => {
14
19
  return {
15
20
  HEADER_OPTIONS: [
@@ -60,55 +65,29 @@ export const optionsStore = derived(T, ($T) => {
60
65
  { id: id(), value: "underline", name: $T("constructor.props.underline"), icon: PROPS_ICONS.underline },
61
66
  { id: id(), value: "background", name: $T("constructor.props.background"), icon: PROPS_ICONS.highlight },
62
67
  ],
63
- /* Семантическая палитра темы: те же роли, что у мастер-цвета виджетов; свотч показывает чистый цвет Apple (--X-mark), как у тегов; bg-max - нейтральный вариант, свотч с ним отмечается рамкой */
68
+ /* Семантическая палитра темы: те же роли, что у мастер-цвета виджетов; свотч показывает яркий цвет гаммы (--X-mark), как у тегов; порядок по кругу тонов, серый первым; bg-max - нейтральный вариант, свотч с ним отмечается рамкой */
64
69
  COLOR_OPTIONS: [
65
70
  { id: id(), name: "-", value: "bg-max", class: "bg-max text-transparent" },
71
+ { id: id(), name: "", value: "bg-gray", class: "bg-gray [--bg-color:var(--gray-mark)]!" },
66
72
  { id: id(), name: "", value: "bg-red", class: "bg-red [--bg-color:var(--red-mark)]!" },
67
73
  { id: id(), name: "", value: "bg-orange", class: "bg-orange [--bg-color:var(--orange-mark)]!" },
68
74
  { id: id(), name: "", value: "bg-yellow", class: "bg-yellow [--bg-color:var(--yellow-mark)]!" },
69
75
  { id: id(), name: "", value: "bg-green", class: "bg-green [--bg-color:var(--green-mark)]!" },
76
+ { id: id(), name: "", value: "bg-cyan", class: "bg-cyan [--bg-color:var(--cyan-mark)]!" },
70
77
  { id: id(), name: "", value: "bg-blue", class: "bg-blue [--bg-color:var(--blue-mark)]!" },
71
78
  { id: id(), name: "", value: "bg-purple", class: "bg-purple [--bg-color:var(--purple-mark)]!" },
72
- { id: id(), name: "", value: "bg-gray", class: "bg-gray [--bg-color:var(--gray-mark)]!" },
73
79
  ],
80
+ /* Цвет текста из палитры темы (--X-text, контраст от 4.5:1), порядок как у мастер-цвета; первый вариант - обычный цвет текста */
74
81
  TEXT_COLOR_OPTIONS: [
75
- {
76
- id: "TEXT_COLOR_SHADOW",
77
- name: "-",
78
- value: "text-[#333] dark:text-[#e2e3e7]",
79
- class: "bg-[var(--shadow-color)] dark:bg-[#e2e3e7] border-[var(--shadow-color)] dark:border-[#e2e3e7] text-transparent",
80
- },
81
- { id: "TEXT_COLOR_RED", name: "", value: "text-red-500 dark:text-red-400", class: "bg-red-500 dark:bg-red-400 border-red-500 dark:border-red-400" },
82
- {
83
- id: "TEXT_COLOR_YELLOW",
84
- name: "",
85
- value: "text-yellow-500 dark:text-yellow-400",
86
- class: "bg-yellow-500 dark:bg-yellow-400 border-yellow-500 dark:border-yellow-400",
87
- },
88
- {
89
- id: "TEXT_COLOR_GREEN",
90
- name: "",
91
- value: "text-green-500 dark:text-green-400",
92
- class: "bg-green-500 dark:bg-green-400 border-green-500 dark:border-green-400",
93
- },
94
- {
95
- id: "TEXT_COLOR_BLUE",
96
- name: "",
97
- value: "text-blue-500 dark:text-blue-400",
98
- class: "bg-blue-500 dark:bg-blue-400 border-blue-500 dark:border-blue-400",
99
- },
100
- {
101
- id: "TEXT_COLOR_PURPLE",
102
- name: "",
103
- value: "text-purple-500 dark:text-purple-400",
104
- class: "bg-purple-500 dark:bg-purple-400 border-purple-500 dark:border-purple-400",
105
- },
106
- {
107
- id: "TEXT_COLOR_GRAY",
108
- name: "",
109
- value: "text-gray-500 dark:text-gray-400",
110
- class: "bg-gray-500 dark:bg-gray-400 border-gray-500 dark:border-gray-400",
111
- },
82
+ { id: "TEXT_COLOR_DEFAULT", name: "-", value: "text-(color:--font-color)", class: "bg-(--font-color) text-transparent" },
83
+ { id: "TEXT_COLOR_GRAY", name: "", value: "text-(color:--gray-text)", class: "[--bg-color:var(--gray-mark)]! bg-(--gray-mark)" },
84
+ { id: "TEXT_COLOR_RED", name: "", value: "text-(color:--red-text)", class: "[--bg-color:var(--red-mark)]! bg-(--red-mark)" },
85
+ { id: "TEXT_COLOR_ORANGE", name: "", value: "text-(color:--orange-text)", class: "[--bg-color:var(--orange-mark)]! bg-(--orange-mark)" },
86
+ { id: "TEXT_COLOR_YELLOW", name: "", value: "text-(color:--yellow-text)", class: "[--bg-color:var(--yellow-mark)]! bg-(--yellow-mark)" },
87
+ { id: "TEXT_COLOR_GREEN", name: "", value: "text-(color:--green-text)", class: "[--bg-color:var(--green-mark)]! bg-(--green-mark)" },
88
+ { id: "TEXT_COLOR_CYAN", name: "", value: "text-(color:--cyan-text)", class: "[--bg-color:var(--cyan-mark)]! bg-(--cyan-mark)" },
89
+ { id: "TEXT_COLOR_BLUE", name: "", value: "text-(color:--blue-text)", class: "[--bg-color:var(--blue-mark)]! bg-(--blue-mark)" },
90
+ { id: "TEXT_COLOR_PURPLE", name: "", value: "text-(color:--purple-text)", class: "[--bg-color:var(--purple-mark)]! bg-(--purple-mark)" },
112
91
  ],
113
92
  TEXT_ALIGN_OPTIONS: [
114
93
  { id: id(), value: "text-left", name: $T("constructor.props.align.left"), icon: PROPS_ICONS.alignLeft },
package/dist/theme.css CHANGED
@@ -337,62 +337,65 @@
337
337
  --faint-color: #5f6774;
338
338
 
339
339
  --accent-color: var(--blue-color);
340
- --accent-hover: #005fc7;
341
- --accent-soft: rgb(0 122 255 / 0.14);
340
+ --accent-hover: #135ae4;
341
+ --accent-soft: rgb(47 117 255 / 0.14);
342
342
  --on-accent: #ffffff;
343
343
  --on-orange: #1d1d1f;
344
344
  --on-yellow: #1d1d1f;
345
+ --on-cyan: #1d1d1f;
345
346
 
346
347
  --shadow-color: #34343a;
347
348
  --border-shadow-color: 0 1px 2px rgb(16 24 40 / 0.05);
348
- --focus-shadow-color: 0 0 0 3px rgb(0 122 255 / 0.22);
349
+ --focus-shadow-color: 0 0 0 3px rgb(47 117 255 / 0.22);
349
350
  --elevation-1: 0 1px 2px rgb(16 24 40 / 0.06), 0 2px 6px rgb(16 24 40 / 0.04);
350
351
  --elevation-2: 0 4px 12px rgb(16 24 40 / 0.08);
351
352
  --elevation-3: 0 12px 32px rgb(16 24 40 / 0.12);
352
353
  --scrollbar-color: #c4c9d2;
353
354
 
354
- /* Цвета Apple. Заливки под белый текст: тон Apple, светлота подобрана под контраст с белым ≥ 4.6:1. Оранжевый и жёлтый - чистые цвета Apple под тёмный текст --on-orange и --on-yellow */
355
+ /* Ровная гамма OKLCH: тоны 27, 58, 98, 150, 225, 262, 310, соседние цвета различаются одинаково хорошо. Заливки под белый текст: светлота подобрана под контраст с белым (светлая тема от 4.6:1, тёмная от 5.2:1). Оранжевый, жёлтый и голубой яркие, под тёмный текст --on-orange, --on-yellow и --on-cyan */
355
356
  --gray-color: #e4e7ec;
356
- --red-color: #ea0c00;
357
- --orange-color: #ff9500;
358
- --yellow-color: #ffcc00;
359
- --green-color: #23863c;
360
- --cyan-color: #157cac;
361
- --blue-color: #0070eb;
362
- --purple-color: #a944db;
357
+ /* Серый как мастер-цвет: --gray-color это светлая поверхность, для акцента нужен средний серый под белый текст */
358
+ --gray-accent: #74747a;
359
+ --red-color: #e22729;
360
+ --orange-color: #fb8900;
361
+ --yellow-color: #f4d400;
362
+ --green-color: #00873d;
363
+ --cyan-color: #00c3f5;
364
+ --blue-color: #256bf7;
365
+ --purple-color: #a448dc;
363
366
  --pink-color: #ea002d;
364
367
 
365
368
  /* Цветной текст: контраст ≥ 4.5:1 на всех фонах темы и на своём --*-soft */
366
369
  --gray-text: var(--muted-color);
367
- --red-text: #c30a00;
368
- --orange-text: #8d5200;
369
- --yellow-text: #755e00;
370
- --green-text: #1d6f32;
371
- --cyan-text: #11678f;
372
- --blue-text: #005dc3;
373
- --purple-text: #9327ca;
370
+ --red-text: #c70014;
371
+ --orange-text: #a25600;
372
+ --yellow-text: #7c6a00;
373
+ --green-text: #007b36;
374
+ --cyan-text: #007494;
375
+ --blue-text: #135ae4;
376
+ --purple-text: #9334c9;
374
377
  --pink-text: #c40025;
375
378
 
376
379
  /* Мягкие тинты для фонов блоков и подсветки строк */
377
380
  --gray-soft: #e1e5ea;
378
- --red-soft: #ffd8d6;
379
- --orange-soft: #ffeacc;
380
- --yellow-soft: #fff5cc;
381
- --green-soft: #d6f4de;
382
- --cyan-soft: #d6effa;
383
- --blue-soft: #cce4ff;
384
- --purple-soft: #efdcf8;
381
+ --red-soft: #ffd3d4;
382
+ --orange-soft: #fee7cc;
383
+ --yellow-soft: #fdf6cc;
384
+ --green-soft: #ccf5df;
385
+ --cyan-soft: #ccf3fd;
386
+ --blue-soft: #d5e3ff;
387
+ --purple-soft: #f0dafd;
385
388
  --pink-soft: #ffd5dd;
386
389
 
387
- /* Метки: чистые цвета Apple для полос, точек и индикаторов, не для текста */
390
+ /* Метки: самые яркие цвета гаммы для полос, точек, тегов и индикаторов, не для текста */
388
391
  --gray-mark: #8e8e93;
389
- --red-mark: #ff3b30;
390
- --orange-mark: #ff9500;
391
- --yellow-mark: #ffcc00;
392
- --green-mark: #34c759;
393
- --cyan-mark: #32ade6;
394
- --blue-mark: #007aff;
395
- --purple-mark: #af52de;
392
+ --red-mark: #ff252a;
393
+ --orange-mark: #fb8900;
394
+ --yellow-mark: #f4d400;
395
+ --green-mark: #00cc5f;
396
+ --cyan-mark: #00c3f5;
397
+ --blue-mark: #2f75ff;
398
+ --purple-mark: #b345f3;
396
399
  --pink-mark: #ff2d55;
397
400
  }
398
401
 
@@ -410,62 +413,65 @@
410
413
  --faint-color: #939cac;
411
414
 
412
415
  --accent-color: var(--blue-color);
413
- --accent-hover: #2f7fd0;
414
- --accent-soft: rgb(10 132 255 / 0.2);
416
+ --accent-hover: #2f72f6;
417
+ --accent-soft: rgb(65 129 255 / 0.2);
415
418
  --on-accent: #ffffff;
416
419
  --on-orange: #1d1d1f;
417
420
  --on-yellow: #1d1d1f;
421
+ --on-cyan: #1d1d1f;
418
422
 
419
423
  --shadow-color: #000000;
420
424
  --border-shadow-color: 0 1px 2px rgb(0 0 0 / 0.4);
421
- --focus-shadow-color: 0 0 0 3px rgb(10 132 255 / 0.32);
425
+ --focus-shadow-color: 0 0 0 3px rgb(65 129 255 / 0.32);
422
426
  --elevation-1: 0 1px 2px rgb(0 0 0 / 0.4);
423
427
  --elevation-2: 0 4px 12px rgb(0 0 0 / 0.45);
424
428
  --elevation-3: 0 12px 32px rgb(0 0 0 / 0.5);
425
429
  --scrollbar-color: #333a47;
426
430
 
427
- /* Цвета Apple. Заливки под белый текст: тон Apple, светлота подобрана под контраст с белым ≥ 5.2:1. Оранжевый и жёлтый - чистые цвета Apple под тёмный текст */
431
+ /* Ровная гамма OKLCH: тоны 27, 58, 98, 150, 225, 262, 310, соседние цвета различаются одинаково хорошо. Заливки под белый текст: светлота подобрана под контраст с белым (светлая тема от 4.6:1, тёмная от 5.2:1). Оранжевый, жёлтый и голубой яркие, под тёмный текст --on-orange, --on-yellow и --on-cyan */
428
432
  --gray-color: #2b313d;
429
- --red-color: #cc3027;
430
- --orange-color: #ff9f0a;
431
- --yellow-color: #ffd60a;
432
- --green-color: #187d31;
433
- --cyan-color: #1d7498;
434
- --blue-color: #236eba;
435
- --purple-color: #aa2ad6;
433
+ /* Серый как мастер-цвет: --gray-color это светлая поверхность, для акцента нужен средний серый под белый текст */
434
+ --gray-accent: #6c6c71;
435
+ --red-color: #d7141e;
436
+ --orange-color: #ff9739;
437
+ --yellow-color: #ffde0b;
438
+ --green-color: #007d37;
439
+ --cyan-color: #27cdff;
440
+ --blue-color: #1c62ed;
441
+ --purple-color: #9c3ed2;
436
442
  --pink-color: #ce2749;
437
443
 
438
- /* Цветной текст: варианты Apple для повышенного контраста, ≥ 4.5:1 на всех фонах темы и на своём --*-soft */
444
+ /* Цветной текст: контраст от 6:1 на всех фонах темы и на своём --*-soft */
439
445
  --gray-text: var(--muted-color);
440
- --red-text: #ff6961;
441
- --orange-text: #ffb340;
442
- --yellow-text: #ffd426;
443
- --green-text: #30db5b;
444
- --cyan-text: #70d7ff;
445
- --blue-text: #409cff;
446
- --purple-text: #da8fff;
446
+ --red-text: #ff9d92;
447
+ --orange-text: #ffb479;
448
+ --yellow-text: #f1d200;
449
+ --green-text: #0ee56c;
450
+ --cyan-text: #69d7ff;
451
+ --blue-text: #94baff;
452
+ --purple-text: #d8a2ff;
447
453
  --pink-text: #ff6482;
448
454
 
449
455
  /* Мягкие тинты для фонов блоков и подсветки строк */
450
456
  --gray-soft: rgb(255 255 255 / 0.1);
451
- --red-soft: rgb(255 69 58 / 0.2);
452
- --orange-soft: rgb(255 159 10 / 0.2);
453
- --yellow-soft: rgb(255 214 10 / 0.2);
454
- --green-soft: rgb(48 209 88 / 0.2);
455
- --cyan-soft: rgb(100 210 255 / 0.2);
456
- --blue-soft: rgb(10 132 255 / 0.2);
457
- --purple-soft: rgb(191 90 242 / 0.2);
457
+ --red-soft: rgb(255 75 68 / 0.2);
458
+ --orange-soft: rgb(255 151 57 / 0.2);
459
+ --yellow-soft: rgb(255 222 11 / 0.2);
460
+ --green-soft: rgb(0 216 101 / 0.2);
461
+ --cyan-soft: rgb(39 205 255 / 0.2);
462
+ --blue-soft: rgb(65 129 255 / 0.2);
463
+ --purple-soft: rgb(189 80 253 / 0.2);
458
464
  --pink-soft: rgb(255 55 95 / 0.2);
459
465
 
460
- /* Метки: чистые цвета Apple для полос, точек и индикаторов, не для текста */
466
+ /* Метки: самые яркие цвета гаммы для полос, точек, тегов и индикаторов, не для текста */
461
467
  --gray-mark: #98989d;
462
- --red-mark: #ff453a;
463
- --orange-mark: #ff9f0a;
464
- --yellow-mark: #ffd60a;
465
- --green-mark: #30d158;
466
- --cyan-mark: #64d2ff;
467
- --blue-mark: #0a84ff;
468
- --purple-mark: #bf5af2;
468
+ --red-mark: #ff4b44;
469
+ --orange-mark: #ff9739;
470
+ --yellow-mark: #ffde0b;
471
+ --green-mark: #00d865;
472
+ --cyan-mark: #27cdff;
473
+ --blue-mark: #4181ff;
474
+ --purple-mark: #bd50fd;
469
475
  --pink-mark: #ff375f;
470
476
  }
471
477
 
@@ -484,6 +490,7 @@
484
490
  }
485
491
  }
486
492
 
493
+ /* Каждая заливка задаёт и цвет текста на себе (--on-accent), иначе кнопка своего цвета внутри виджета берёт текст от мастер-цвета виджета */
487
494
  /* ─── Утилиты заливки (без изменений в именах) ───────────────────────── */
488
495
  .bg-max {
489
496
  --bg-color: var(--back-color);
@@ -493,6 +500,7 @@
493
500
  }
494
501
  .bg-red {
495
502
  --bg-color: var(--red-color);
503
+ --on-accent: #ffffff;
496
504
  }
497
505
  .bg-orange {
498
506
  --bg-color: var(--orange-color);
@@ -504,18 +512,23 @@
504
512
  }
505
513
  .bg-green {
506
514
  --bg-color: var(--green-color);
515
+ --on-accent: #ffffff;
507
516
  }
508
517
  .bg-cyan {
509
518
  --bg-color: var(--cyan-color);
519
+ --on-accent: var(--on-cyan);
510
520
  }
511
521
  .bg-blue {
512
522
  --bg-color: var(--blue-color);
523
+ --on-accent: #ffffff;
513
524
  }
514
525
  .bg-purple {
515
526
  --bg-color: var(--purple-color);
527
+ --on-accent: #ffffff;
516
528
  }
517
529
  .bg-pink {
518
530
  --bg-color: var(--pink-color);
531
+ --on-accent: #ffffff;
519
532
  }
520
533
 
521
534
  /* Мягкие варианты - для карточек, плашек и подсветки, где заливка не должна кричать */
@@ -575,6 +588,16 @@
575
588
  --border-color: var(--pink-color);
576
589
  }
577
590
 
591
+ /* Нативные чекбоксы, радиокнопки и ползунки окрашиваются акцентом: внутри виджета с мастер-цветом - его цветом */
592
+ @layer base {
593
+ input[type="checkbox"],
594
+ input[type="radio"],
595
+ input[type="range"],
596
+ progress {
597
+ accent-color: var(--accent-color);
598
+ }
599
+ }
600
+
578
601
  /* Подсказка placeholder */
579
602
  @layer base {
580
603
  input::placeholder,
package/dist/types.d.ts CHANGED
@@ -69,6 +69,7 @@ export interface IAccordionProps {
69
69
  class?: string;
70
70
  icon?: ConstructorOfATypedSvelteComponent | string | null;
71
71
  };
72
+ chevron?: boolean;
72
73
  children?: Snippet;
73
74
  actions?: Snippet;
74
75
  image?: string;
@@ -7,3 +7,4 @@ export interface IMapColors {
7
7
  orange: string;
8
8
  }
9
9
  export declare const readMapColors: (el: Element | undefined) => IMapColors;
10
+ export declare const itemAccentStyle: (classString: string | undefined) => string | undefined;
@@ -7,18 +7,23 @@ export const widgetAccentStyle = (componentClass) => {
7
7
  const role = componentClass.match(/(?:^|\s)bg-(\w+)/)?.[1];
8
8
  if (!role || role === "max")
9
9
  return fill;
10
- return (`--accent-color: var(--${role}-color); --accent-soft: var(--${role}-soft); --accent-hover: var(--${role}-color); --on-accent: var(--on-${role}, #ffffff);` +
11
- `--focus-shadow-color: 0 0 0 3px color-mix(in srgb, var(--${role}-color) 18%, transparent);` +
10
+ return (`--accent-color: var(--${role}-accent, var(--${role}-color)); --accent-soft: var(--${role}-soft); --accent-hover: var(--${role}-accent, var(--${role}-color)); --on-accent: var(--on-${role}, #ffffff);` +
11
+ `--focus-shadow-color: 0 0 0 3px color-mix(in srgb, var(--${role}-accent, var(--${role}-color)) 18%, transparent);` +
12
12
  fill);
13
13
  };
14
14
  export const readMapColors = (el) => {
15
15
  const style = el ? getComputedStyle(el) : null;
16
16
  const read = (name, fallback) => style?.getPropertyValue(name).trim() || fallback;
17
17
  return {
18
- accent: read("--accent-color", "#0070eb"),
18
+ accent: read("--accent-color", "#256bf7"),
19
19
  onAccent: read("--on-accent", "#ffffff"),
20
- green: read("--green-mark", "#34c759"),
21
- red: read("--red-mark", "#ff3b30"),
22
- orange: read("--orange-mark", "#ff9500"),
20
+ green: read("--green-mark", "#00cc5f"),
21
+ red: read("--red-mark", "#ff252a"),
22
+ orange: read("--orange-mark", "#fb8900"),
23
23
  };
24
24
  };
25
+ /* Мастер-цвет отдельного элемента (столбец прогресса, переключатель, пункт выбора): только если в классах есть роль bg-*, иначе элемент берёт цвет родителя */
26
+ export const itemAccentStyle = (classString) => {
27
+ const role = classString?.match(/(?:^|\s)bg-(\w+)/)?.[1];
28
+ return role && role !== "max" ? widgetAccentStyle(classString) : undefined;
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.96.0",
3
+ "version": "1.98.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Oleg-Perevyshin/ElementsUI.git"