@hia/theme-core 0.5.0 → 0.6.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/dist/color/color-name.js +30 -12
- package/dist/data/mood-primary-colors.d.ts +77 -0
- package/dist/data/mood-primary-colors.js +83 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/studio.js +12 -2
- package/dist/theme.js +14 -6
- package/package.json +1 -1
package/dist/color/color-name.js
CHANGED
|
@@ -36,29 +36,47 @@ export function modifierFor(L, C) {
|
|
|
36
36
|
return C > 0.14 ? 'deep' : 'dark';
|
|
37
37
|
return C > 0.12 ? 'deep' : 'dark';
|
|
38
38
|
}
|
|
39
|
-
// 色相角 →
|
|
40
|
-
//
|
|
39
|
+
// 色相角 → 色相名(含棕与品红/粉的明度区分)。
|
|
40
|
+
// **分区锚点是 OKLCH 色相角,不是 sRGB 色相角**——两者的零点与刻度都不同:
|
|
41
|
+
// 纯红 sRGB 0° / OKLCH 29°,纯黄 60° / 110°,纯绿 120° / 143°,纯蓝 240° / 264°。
|
|
42
|
+
// 早前版本按 sRGB 分区(`<15` 判红等)却传入 OKLCH 角,导致整环错位约 30°:
|
|
43
|
+
// 纯红 `#FF0000` 被叫成"强橙"、纯黄 `#FFFF00` 被叫成"亮绿"。分区锚点即以标准色的 OKLCH 角为准。
|
|
44
|
+
// <lang en>Hue angle → hue name (brown/pink resolved by lightness). **The sector anchors are OKLCH hue angles,
|
|
45
|
+
// not sRGB ones** — the two differ in both origin and spacing: pure red is sRGB 0° but OKLCH 29°, yellow 60° vs
|
|
46
|
+
// 110°, green 120° vs 143°, blue 240° vs 264°. An earlier version used sRGB sectors on OKLCH angles, shifting
|
|
47
|
+
// the whole ring by ~30° so pure red `#FF0000` was named "strong orange" and pure yellow "brilliant green".
|
|
48
|
+
// The anchors below are the OKLCH angles of the canonical hues.</lang>
|
|
41
49
|
export function hueNameFor(h, L, C) {
|
|
42
50
|
if (C < 0.04)
|
|
43
51
|
return L > 0.9 ? 'white' : L > 0.35 ? 'grey' : 'black';
|
|
44
52
|
const deg = ((h % 360) + 360) % 360;
|
|
45
|
-
|
|
53
|
+
// 红 29° / 橙 53° / 黄 110° / 绿 143° / 青 195° / 蓝 264° / 紫 294° / 品红 328°。
|
|
54
|
+
// 区间边界取相邻锚点的中点:红↔橙 41、橙↔黄 82、黄↔绿 126、绿↔青 169、青↔蓝 230、蓝↔紫 279、紫↔品红 311。
|
|
55
|
+
// 红与品红在 360/0 处首尾相接:品红锚点 328° 到红锚点 29°,中点 358.5°——
|
|
56
|
+
// 故 ≥358.5 归品红、18–41 归红。这样洋红 `#A2007C`(342°)读作品红而不是"深红"。
|
|
57
|
+
// <lang en>Sector boundaries are midpoints between adjacent anchors: red↔orange 41, orange↔yellow 82,
|
|
58
|
+
// yellow↔green 126, green↔cyan 169, cyan↔blue 230, blue↔purple 279, purple↔magenta 311. Red and magenta
|
|
59
|
+
// meet across 360/0: magenta 328° to red 29° has its midpoint at 358.5°, so ≥358.5 reads magenta and 18–41
|
|
60
|
+
// reads red. That keeps magenta `#A2007C` (342°) out of the red sector.</lang>
|
|
61
|
+
if (deg < 18)
|
|
46
62
|
return L < 0.45 ? 'brown' : 'red';
|
|
47
|
-
if (deg <
|
|
48
|
-
return L < 0.45 ? 'brown' : '
|
|
49
|
-
if (deg <
|
|
63
|
+
if (deg < 41)
|
|
64
|
+
return L < 0.45 ? 'brown' : 'red';
|
|
65
|
+
if (deg < 82)
|
|
66
|
+
return L < 0.5 ? 'brown' : 'orange';
|
|
67
|
+
if (deg < 126)
|
|
50
68
|
return 'yellow';
|
|
51
|
-
if (deg <
|
|
69
|
+
if (deg < 169)
|
|
52
70
|
return 'green';
|
|
53
|
-
if (deg <
|
|
71
|
+
if (deg < 230)
|
|
54
72
|
return 'cyan';
|
|
55
|
-
if (deg <
|
|
73
|
+
if (deg < 279)
|
|
56
74
|
return 'blue';
|
|
57
|
-
if (deg <
|
|
75
|
+
if (deg < 311)
|
|
58
76
|
return 'purple';
|
|
59
|
-
if (deg <
|
|
77
|
+
if (deg < 358.5)
|
|
60
78
|
return L > 0.7 ? 'pink' : 'magenta';
|
|
61
|
-
return L
|
|
79
|
+
return L < 0.45 ? 'brown' : 'red';
|
|
62
80
|
}
|
|
63
81
|
/** @lang zh-CN 由 HEX 生成结构化色名(修饰语+色相,中英双语)。
|
|
64
82
|
* @lang en Builds a structured bilingual color name (modifier + hue) from hex. */
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lang zh-CN **情感主色独立数据集**(`W-tb-P34`,维护者校正后重做)。
|
|
3
|
+
*
|
|
4
|
+
* **为什么是独立数据集**:维护者明确要求"情感主色不能关联其它颜色数据"。
|
|
5
|
+
* 早前版本把 24 情感映射到 44 个主色候选库(宝典首色频次 → OKLab 最近邻 → 投票),
|
|
6
|
+
* 结果是语义无关的颜色被最近邻吸到同几个点上(低沉→亮黄、平和→粉红、四个情感挤在同一个粉色),
|
|
7
|
+
* 一望即知是错的。根因不是参数没调好,是**方法本身串了数据源**:候选库是"网站/流行色"的策展集合,
|
|
8
|
+
* 与情感语义没有关系。
|
|
9
|
+
*
|
|
10
|
+
* 本表自带色值,不引用 `primaryCandidates`,也与它零耦合——改候选库不影响本表,反之亦然。
|
|
11
|
+
*
|
|
12
|
+
* **取色依据**:配色宝典为每个情感提供八种组合形态的具体色号,
|
|
13
|
+
* 其中 **单色色彩组合(单色系)** 只用一个色相做明暗变化,最接近"该情感的色彩主张";
|
|
14
|
+
* 其余形态(补色/冲突/三元)混入对比色相,取"首色"只会得到组合排列的噪声。
|
|
15
|
+
* 每条的 `anchor` 是该情感单色系里**只用单一色号的那个组合**(即该情感的核本色相),
|
|
16
|
+
* `secondary` 取该情感单色系中出现频次最高的兄弟色号(同色相不同明暗,天然成对)。
|
|
17
|
+
*
|
|
18
|
+
* 这与宝典的文字描述一致:强烈=离不开红、热情=金橙、平静=蓝、低沉=灰紫、专职=灰黑底衬。
|
|
19
|
+
*
|
|
20
|
+
* **色名为什么有策展值**:自动命名只有 9 档修饰语 × 13 个色相,同一色系的相邻明暗阶必然撞名
|
|
21
|
+
* ——`#DF0029` 与 `#E33539` 都会得到"强红"、古典与可靠都会得到"暗蓝"。这在 44 色候选库里无伤大雅
|
|
22
|
+
* (本来就有分组),但摆在 24 张情感卡上就是明晃晃的重复。故对**撞名的那 8 条**给出策展色名,
|
|
23
|
+
* 其余 16 条仍是自动命名的结果。策展名与色值一一对应,由单测守住(同名即失败)。
|
|
24
|
+
*
|
|
25
|
+
* @lang en **Standalone mood → primary dataset** (`W-tb-P34`, redone after the maintainer's correction).
|
|
26
|
+
*
|
|
27
|
+
* **Why standalone**: the maintainer required that mood primaries must not be tied to any other colour
|
|
28
|
+
* dataset. An earlier version mapped the 24 moods onto the 44-candidate primary library (leading-colour
|
|
29
|
+
* frequency → OKLab nearest neighbour → weighted vote), and semantically unrelated colours collapsed onto
|
|
30
|
+
* the same few points (低沉→bright yellow, 平静→pink, four moods on one pink). The cause was the method
|
|
31
|
+
* mixing datasets, not bad tuning: the candidate library is a curated set of site/trending colours and has
|
|
32
|
+
* nothing to do with mood semantics.
|
|
33
|
+
*
|
|
34
|
+
* This table carries its own colours, references no `primaryCandidates`, and is fully decoupled from it.
|
|
35
|
+
*
|
|
36
|
+
* **Colour source**: the colour handbook gives concrete palette numbers for eight combo forms per mood.
|
|
37
|
+
* **Mono (single-hue) combos** vary one hue's lightness only, which is closest to "this mood's colour
|
|
38
|
+
* claim"; the other forms mix contrasting hues, so their leading colour is mostly arrangement noise.
|
|
39
|
+
* Each row's `anchor` is the palette number used alone in that mood's mono set (the mood's core hue), and
|
|
40
|
+
* `secondary` is the most frequent sibling number in the same set — same hue, different lightness, a natural
|
|
41
|
+
* pair. This matches the handbook's own prose: 强烈 = red-bound, 热情 = golden orange, 平静 = blue,
|
|
42
|
+
* 低沉 = grey-purple, 专职 = grey/black base under accents.
|
|
43
|
+
*/
|
|
44
|
+
/** @lang zh-CN 一条情感主色记录。 @lang en One mood-primary record. */
|
|
45
|
+
export interface MoodPrimaryColor {
|
|
46
|
+
/** @lang zh-CN 情感名(与 `TONE_MOODS` 同源)。 @lang en Mood name (same source as `TONE_MOODS`). */
|
|
47
|
+
mood: string;
|
|
48
|
+
/** @lang zh-CN 宝典色号(可回溯到宝典单色系组合)。 @lang en Handbook palette number (traceable to the mono combo). */
|
|
49
|
+
anchor: number;
|
|
50
|
+
/** @lang zh-CN 主色 HEX(该情感的核本色相)。 @lang en Primary HEX (the mood's core hue). */
|
|
51
|
+
hex: string;
|
|
52
|
+
/** @lang zh-CN 主色中文色名。 @lang en Primary Chinese colour name. */
|
|
53
|
+
zh: string;
|
|
54
|
+
/** @lang zh-CN 主色英文色名。 @lang en Primary English colour name. */
|
|
55
|
+
en: string;
|
|
56
|
+
/** @lang zh-CN 同色系兄弟色号(该情感单色系里频次最高的另一色)。 @lang en Sibling number (most frequent other shade in the mono set). */
|
|
57
|
+
secondaryAnchor: number;
|
|
58
|
+
/** @lang zh-CN 副色 HEX。 @lang en Secondary HEX. */
|
|
59
|
+
secondaryHex: string;
|
|
60
|
+
/** @lang zh-CN 副色中文色名。 @lang en Secondary Chinese colour name. */
|
|
61
|
+
secondaryZh: string;
|
|
62
|
+
/** @lang zh-CN 副色英文色名。 @lang en Secondary English colour name. */
|
|
63
|
+
secondaryEn: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @lang zh-CN 24 情感 → 核本色相与同色系副色(独立数据集,不与主色候选库关联)。
|
|
67
|
+
* 顺序与 `TONE_MOODS` 一致,便于 UI 稳定呈现。
|
|
68
|
+
* @lang en 24 moods → core hue plus its same-hue secondary (standalone; no relation to the candidate library).
|
|
69
|
+
* Ordered like `TONE_MOODS` so the UI renders stably.
|
|
70
|
+
*/
|
|
71
|
+
export declare const MOOD_PRIMARY_COLORS: readonly MoodPrimaryColor[];
|
|
72
|
+
/**
|
|
73
|
+
* @lang zh-CN 按情感名取主色记录;未知情感返回 `undefined`(不编造默认值)。
|
|
74
|
+
* @lang en Looks up a mood record by name; returns `undefined` for unknown moods (never fabricates a default).
|
|
75
|
+
*/
|
|
76
|
+
export declare function moodPrimaryColorFor(mood: string): MoodPrimaryColor | undefined;
|
|
77
|
+
//# sourceMappingURL=mood-primary-colors.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lang zh-CN **情感主色独立数据集**(`W-tb-P34`,维护者校正后重做)。
|
|
3
|
+
*
|
|
4
|
+
* **为什么是独立数据集**:维护者明确要求"情感主色不能关联其它颜色数据"。
|
|
5
|
+
* 早前版本把 24 情感映射到 44 个主色候选库(宝典首色频次 → OKLab 最近邻 → 投票),
|
|
6
|
+
* 结果是语义无关的颜色被最近邻吸到同几个点上(低沉→亮黄、平和→粉红、四个情感挤在同一个粉色),
|
|
7
|
+
* 一望即知是错的。根因不是参数没调好,是**方法本身串了数据源**:候选库是"网站/流行色"的策展集合,
|
|
8
|
+
* 与情感语义没有关系。
|
|
9
|
+
*
|
|
10
|
+
* 本表自带色值,不引用 `primaryCandidates`,也与它零耦合——改候选库不影响本表,反之亦然。
|
|
11
|
+
*
|
|
12
|
+
* **取色依据**:配色宝典为每个情感提供八种组合形态的具体色号,
|
|
13
|
+
* 其中 **单色色彩组合(单色系)** 只用一个色相做明暗变化,最接近"该情感的色彩主张";
|
|
14
|
+
* 其余形态(补色/冲突/三元)混入对比色相,取"首色"只会得到组合排列的噪声。
|
|
15
|
+
* 每条的 `anchor` 是该情感单色系里**只用单一色号的那个组合**(即该情感的核本色相),
|
|
16
|
+
* `secondary` 取该情感单色系中出现频次最高的兄弟色号(同色相不同明暗,天然成对)。
|
|
17
|
+
*
|
|
18
|
+
* 这与宝典的文字描述一致:强烈=离不开红、热情=金橙、平静=蓝、低沉=灰紫、专职=灰黑底衬。
|
|
19
|
+
*
|
|
20
|
+
* **色名为什么有策展值**:自动命名只有 9 档修饰语 × 13 个色相,同一色系的相邻明暗阶必然撞名
|
|
21
|
+
* ——`#DF0029` 与 `#E33539` 都会得到"强红"、古典与可靠都会得到"暗蓝"。这在 44 色候选库里无伤大雅
|
|
22
|
+
* (本来就有分组),但摆在 24 张情感卡上就是明晃晃的重复。故对**撞名的那 8 条**给出策展色名,
|
|
23
|
+
* 其余 16 条仍是自动命名的结果。策展名与色值一一对应,由单测守住(同名即失败)。
|
|
24
|
+
*
|
|
25
|
+
* @lang en **Standalone mood → primary dataset** (`W-tb-P34`, redone after the maintainer's correction).
|
|
26
|
+
*
|
|
27
|
+
* **Why standalone**: the maintainer required that mood primaries must not be tied to any other colour
|
|
28
|
+
* dataset. An earlier version mapped the 24 moods onto the 44-candidate primary library (leading-colour
|
|
29
|
+
* frequency → OKLab nearest neighbour → weighted vote), and semantically unrelated colours collapsed onto
|
|
30
|
+
* the same few points (低沉→bright yellow, 平静→pink, four moods on one pink). The cause was the method
|
|
31
|
+
* mixing datasets, not bad tuning: the candidate library is a curated set of site/trending colours and has
|
|
32
|
+
* nothing to do with mood semantics.
|
|
33
|
+
*
|
|
34
|
+
* This table carries its own colours, references no `primaryCandidates`, and is fully decoupled from it.
|
|
35
|
+
*
|
|
36
|
+
* **Colour source**: the colour handbook gives concrete palette numbers for eight combo forms per mood.
|
|
37
|
+
* **Mono (single-hue) combos** vary one hue's lightness only, which is closest to "this mood's colour
|
|
38
|
+
* claim"; the other forms mix contrasting hues, so their leading colour is mostly arrangement noise.
|
|
39
|
+
* Each row's `anchor` is the palette number used alone in that mood's mono set (the mood's core hue), and
|
|
40
|
+
* `secondary` is the most frequent sibling number in the same set — same hue, different lightness, a natural
|
|
41
|
+
* pair. This matches the handbook's own prose: 强烈 = red-bound, 热情 = golden orange, 平静 = blue,
|
|
42
|
+
* 低沉 = grey-purple, 专职 = grey/black base under accents.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* @lang zh-CN 24 情感 → 核本色相与同色系副色(独立数据集,不与主色候选库关联)。
|
|
46
|
+
* 顺序与 `TONE_MOODS` 一致,便于 UI 稳定呈现。
|
|
47
|
+
* @lang en 24 moods → core hue plus its same-hue secondary (standalone; no relation to the candidate library).
|
|
48
|
+
* Ordered like `TONE_MOODS` so the UI renders stably.
|
|
49
|
+
*/
|
|
50
|
+
export const MOOD_PRIMARY_COLORS = [
|
|
51
|
+
{ mood: '强烈', anchor: 4, hex: '#DF0029', zh: '烈红', en: 'Fiery Red', secondaryAnchor: 2, secondaryHex: '#B2001F', secondaryZh: '深红', secondaryEn: 'Deep Red' },
|
|
52
|
+
{ mood: '丰富', anchor: 1, hex: '#8B0016', zh: '深棕', en: 'Deep Brown', secondaryAnchor: 2, secondaryHex: '#B2001F', secondaryZh: '深红', secondaryEn: 'Deep Red' },
|
|
53
|
+
{ mood: '浪漫', anchor: 7, hex: '#F5A89A', zh: '浅红', en: 'Light Red', secondaryAnchor: 6, secondaryHex: '#EE7C6B', secondaryZh: '中红', secondaryEn: 'Moderate Red' },
|
|
54
|
+
{ mood: '奔放', anchor: 12, hex: '#E33539', zh: '焰红', en: 'Flame Red', secondaryAnchor: 10, secondaryHex: '#B6292B', secondaryZh: '深红', secondaryEn: 'Deep Red' },
|
|
55
|
+
{ mood: '土性', anchor: 10, hex: '#B6292B', zh: '深红', en: 'Deep Red', secondaryAnchor: 9, secondaryHex: '#8E1E20', secondaryZh: '深棕', secondaryEn: 'Deep Brown' },
|
|
56
|
+
{ mood: '友善', anchor: 20, hex: '#EC870E', zh: '强橙', en: 'Strong Orange', secondaryAnchor: 18, secondaryHex: '#BD6B09', secondaryZh: '中橙', secondaryEn: 'Moderate Orange' },
|
|
57
|
+
{ mood: '柔和', anchor: 22, hex: '#F5B16D', zh: '浅橙', en: 'Light Orange', secondaryAnchor: 19, secondaryHex: '#D0770B', secondaryZh: '中橙', secondaryEn: 'Moderate Orange' },
|
|
58
|
+
{ mood: '热情', anchor: 28, hex: '#F1AF00', zh: '鲜橙', en: 'Vivid Orange', secondaryAnchor: 27, secondaryHex: '#D59B00', secondaryZh: '鲜橙', secondaryEn: 'Vivid Orange' },
|
|
59
|
+
{ mood: '动感', anchor: 36, hex: '#F9F400', zh: '亮黄', en: 'Brilliant Yellow', secondaryAnchor: 34, secondaryHex: '#C7C300', secondaryZh: '鲜黄', secondaryEn: 'Vivid Yellow' },
|
|
60
|
+
{ mood: '高雅', anchor: 39, hex: '#FFFAB3', zh: '淡黄', en: 'Pale Yellow', secondaryAnchor: 35, secondaryHex: '#DCD800', secondaryZh: '鲜黄', secondaryEn: 'Vivid Yellow' },
|
|
61
|
+
{ mood: '流行', anchor: 44, hex: '#5BBD2B', zh: '强绿', en: 'Strong Green', secondaryAnchor: 42, secondaryHex: '#489620', secondaryZh: '强绿', secondaryEn: 'Strong Green' },
|
|
62
|
+
{ mood: '清新', anchor: 52, hex: '#00A06B', zh: '中绿', en: 'Moderate Green', secondaryAnchor: 49, secondaryHex: '#006241', secondaryZh: '暗绿', secondaryEn: 'Dark Green' },
|
|
63
|
+
{ mood: '传统', anchor: 49, hex: '#006241', zh: '暗绿', en: 'Dark Green', secondaryAnchor: 51, secondaryHex: '#008C5E', secondaryZh: '中绿', secondaryEn: 'Moderate Green' },
|
|
64
|
+
{ mood: '清爽', anchor: 60, hex: '#00A6AD', zh: '中青', en: 'Moderate Cyan', secondaryAnchor: 59, secondaryHex: '#009298', secondaryZh: '中青', secondaryEn: 'Moderate Cyan' },
|
|
65
|
+
{ mood: '热带', anchor: 62, hex: '#6EC3C9', zh: '浅青', en: 'Light Cyan', secondaryAnchor: 59, secondaryHex: '#009298', secondaryZh: '中青', secondaryEn: 'Moderate Cyan' },
|
|
66
|
+
{ mood: '古典', anchor: 68, hex: '#205AA7', zh: '宝蓝', en: 'Sapphire Blue', secondaryAnchor: 69, secondaryHex: '#426EB4', secondaryZh: '中蓝', secondaryEn: 'Moderate Blue' },
|
|
67
|
+
{ mood: '可靠', anchor: 65, hex: '#103667', zh: '藏青', en: 'Navy Blue', secondaryAnchor: 67, secondaryHex: '#1B4F93', secondaryZh: '暗蓝', secondaryEn: 'Dark Blue' },
|
|
68
|
+
{ mood: '平静', anchor: 70, hex: '#7388C1', zh: '中蓝', en: 'Moderate Blue', secondaryAnchor: 72, secondaryHex: '#BFCAE6', secondaryZh: '浅蓝', secondaryEn: 'Light Blue' },
|
|
69
|
+
{ mood: '堂皇', anchor: 76, hex: '#3A2885', zh: '深紫', en: 'Deep Purple', secondaryAnchor: 73, secondaryHex: '#211551', secondaryZh: '暗紫', secondaryEn: 'Dark Purple' },
|
|
70
|
+
{ mood: '神奇', anchor: 84, hex: '#5D0C7B', zh: '茄紫', en: 'Eggplant', secondaryAnchor: 86, secondaryHex: '#8C63A4', secondaryZh: '中品红', secondaryEn: 'Moderate Magenta' },
|
|
71
|
+
{ mood: '怀旧', anchor: 86, hex: '#8C63A4', zh: '暮紫', en: 'Dusk Purple', secondaryAnchor: 83, secondaryHex: '#52096C', secondaryZh: '深品红', secondaryEn: 'Deep Magenta' },
|
|
72
|
+
{ mood: '活力', anchor: 92, hex: '#A2007C', zh: '洋红', en: 'Carmine', secondaryAnchor: 90, secondaryHex: '#780062', secondaryZh: '深品红', secondaryEn: 'Deep Magenta' },
|
|
73
|
+
{ mood: '低沉', anchor: 94, hex: '#C57CAC', zh: '灰紫', en: 'Ash Purple', secondaryAnchor: 92, secondaryHex: '#A2007C', secondaryZh: '深品红', secondaryEn: 'Deep Magenta' },
|
|
74
|
+
{ mood: '专职', anchor: 102, hex: '#898989', zh: '中灰', en: 'Moderate Grey', secondaryAnchor: 99, secondaryHex: '#C2C2C2', secondaryZh: '浅灰', secondaryEn: 'Light Grey' }
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* @lang zh-CN 按情感名取主色记录;未知情感返回 `undefined`(不编造默认值)。
|
|
78
|
+
* @lang en Looks up a mood record by name; returns `undefined` for unknown moods (never fabricates a default).
|
|
79
|
+
*/
|
|
80
|
+
export function moodPrimaryColorFor(mood) {
|
|
81
|
+
return MOOD_PRIMARY_COLORS.find(m => m.mood === mood);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=mood-primary-colors.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export { GRADIENT_DEFS, GRADIENT_DEFAULTS, cloneGradientSettings } from './data/
|
|
|
21
21
|
export { BAODIAN_PALETTE, FORM_PACKS, BAODIAN_FORM_NAMES } from './data/palette-packs.js';
|
|
22
22
|
export type { BaodianCombo } from './data/palette-packs.js';
|
|
23
23
|
export { tonePresets, buildTonePreset, TONE_MOODS, TONE_FORM_PRIORITY, TONE_DEFAULT_PRIORITY, TONE_AUX_SLOTS } from './data/tone-presets.js';
|
|
24
|
+
export { MOOD_PRIMARY_COLORS, moodPrimaryColorFor } from './data/mood-primary-colors.js';
|
|
25
|
+
export type { MoodPrimaryColor } from './data/mood-primary-colors.js';
|
|
24
26
|
export { TRADITIONAL_COLORS } from './data/traditional-colors.js';
|
|
25
27
|
export { FLAG_COLORS } from './data/flags.js';
|
|
26
28
|
export type { FlagEntry, Continent } from './data/flags.js';
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,14 @@ export { GRADIENT_DEFS, GRADIENT_DEFAULTS, cloneGradientSettings } from './data/
|
|
|
37
37
|
// <lang en>Auto-extracted from the Peise Baodian CHM source; backs the relation-rule preset dropdown.</lang>
|
|
38
38
|
export { BAODIAN_PALETTE, FORM_PACKS, BAODIAN_FORM_NAMES } from './data/palette-packs.js';
|
|
39
39
|
export { tonePresets, buildTonePreset, TONE_MOODS, TONE_FORM_PRIORITY, TONE_DEFAULT_PRIORITY, TONE_AUX_SLOTS } from './data/tone-presets.js';
|
|
40
|
+
// 情感主色:**独立数据集**(维护者校正后重做),自带色值,不与主色候选库关联。
|
|
41
|
+
// 早前版本曾把情感映射到 44 主色候选(首色频次 + OKLab 最近邻),结果语义错乱,
|
|
42
|
+
// 根因是串了数据源——候选库讲"网站/流行色",与情感语义无关。此表已与候选库完全解耦。
|
|
43
|
+
// <lang en>Mood primaries: a **standalone dataset** (redone after the maintainer's correction) carrying its own
|
|
44
|
+
// colours and decoupled from the primary candidate library. An earlier version mapped moods onto the 44
|
|
45
|
+
// candidates (leading-colour frequency + OKLab nearest neighbour); the results were semantically wrong because
|
|
46
|
+
// the method mixed datasets — the library is about site/trending colours and says nothing about mood.</lang>
|
|
47
|
+
export { MOOD_PRIMARY_COLORS, moodPrimaryColorFor } from './data/mood-primary-colors.js';
|
|
40
48
|
export { TRADITIONAL_COLORS } from './data/traditional-colors.js';
|
|
41
49
|
export { FLAG_COLORS } from './data/flags.js';
|
|
42
50
|
export { BRAND_COLORS } from './data/brand-colors.js';
|
package/dist/studio.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeHex } from './color/convert.js';
|
|
2
|
+
import { nameColor } from './color/color-name.js';
|
|
2
3
|
import { generateSecondarySet } from './color/harmony.js';
|
|
3
4
|
import { cloneGradientSettings, GRADIENT_DEFAULTS } from './data/gradients.js';
|
|
4
5
|
import { DEFAULT_SPACING, DEFAULT_TYPOGRAPHY } from './token/typography.js';
|
|
@@ -10,7 +11,16 @@ export const DEFAULT_THEME_DRAFT = { id: 'preset-default', name: 'HIA 默认', c
|
|
|
10
11
|
// 依据主副色中文名自动拼出主题名,缺省提供可读回退。
|
|
11
12
|
// <lang zh-CN>用于用户未手动命名时给出“主色·副色”式默认标题。</lang>
|
|
12
13
|
// <lang en>Yields a "primary·secondary" default title when the user has not named the theme.</lang>
|
|
13
|
-
export function autoThemeName(primaryName, secondaryName) {
|
|
14
|
+
export function autoThemeName(primaryName, secondaryName) {
|
|
15
|
+
const p = primaryName || '主题', s = secondaryName || '副色';
|
|
16
|
+
// 主副同名时不要拼出"鲜橙·鲜橙"这种废话标题。
|
|
17
|
+
// 色名是"修饰语+色相"两档粒度,同色系的深浅两阶会落到同一个名字上(`#F1AF00`/`#D59B00` 都是"鲜橙")——
|
|
18
|
+
// 这不是命名错误,但把两个相同词拼成标题就是明显的敷衍。
|
|
19
|
+
// <lang en>Never emit a "Vivid Orange · Vivid Orange" title. Colour names have modifier+hue granularity, so two
|
|
20
|
+
// shades of one hue can land on the same name (`#F1AF00`/`#D59B00` are both "Vivid Orange") — that is not a
|
|
21
|
+
// naming error, but joining two identical words into a title is plainly careless.</lang>
|
|
22
|
+
return p === s ? p : `${p}·${s}`;
|
|
23
|
+
}
|
|
14
24
|
// 由部分字段创建完整草稿,基色规范化、渐变深拷贝,保证可预测初值。
|
|
15
25
|
// <lang zh-CN>覆盖式合并到默认模板,避免未传字段出现 undefined;纯函数无副作用。</lang>
|
|
16
26
|
// <lang en>Override-merges onto the default template to avoid undefined fields; pure and side-effect-free.</lang>
|
|
@@ -59,7 +69,7 @@ export function buildThemeFromDraft(draft) {
|
|
|
59
69
|
// <lang zh-CN>保存/导出时使用,基色再次规范化确保持久化一致。</lang>
|
|
60
70
|
// <lang en>Used for save/export; base colors are re-normalized for consistent persistence.</lang>
|
|
61
71
|
export function presetFromDraft(draft, id = `custom-${Date.now()}`) {
|
|
62
|
-
return { id, name: draft.name || autoThemeName(draft.primaryName, draft.secondaryName), category: draft.category || 'custom', industry: draft.industry || '', primary: normalizeHex(draft.primary), secondary: normalizeHex(draft.secondary), primaryName: draft.primaryName ||
|
|
72
|
+
return { id, name: draft.name || autoThemeName(draft.primaryName, draft.secondaryName), category: draft.category || 'custom', industry: draft.industry || '', primary: normalizeHex(draft.primary), secondary: normalizeHex(draft.secondary), primaryName: draft.primaryName || nameColor(draft.primary).zh, secondaryName: draft.secondaryName || nameColor(draft.secondary).zh, note: draft.note || '由主副色操作台生成导入。', gradients: cloneGradientSettings(draft.gradients), ...(draft.seriesMode && draft.seriesMode !== 'dual' ? { seriesMode: draft.seriesMode } : {}), ...(draft.seriesRelation && draft.seriesRelation !== 'manual' ? { seriesRelation: draft.seriesRelation } : {}), ...(draft.thirdColor ? { thirdColor: { ...draft.thirdColor, scale: { ...draft.thirdColor.scale } } } : {}), ...(draft.auxiliary?.length ? { auxiliary: draft.auxiliary.map(a => ({ ...a, scale: { ...a.scale } })) } : {}) };
|
|
63
73
|
}
|
|
64
74
|
// 在候选库中按主副色同时匹配出对应候选(用于回显“当前主色”来源)。
|
|
65
75
|
// <lang zh-CN>仅当主色与推荐副色都一致才命中,避免近似色误判。</lang>
|
package/dist/theme.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_TYPOGRAPHY, DEFAULT_SPACING } from './token/typography.js';
|
|
2
|
+
import { nameColor } from './color/color-name.js';
|
|
2
3
|
// 字体令牌深拷贝(ADR-006):阻断外部对象与内部状态的隐含耦合。
|
|
3
4
|
// <lang zh-CN>fontFamily/scale/overrides 逐层复制;overrides 为 undefined 时不显式写入键,
|
|
4
5
|
// 保证 deepEqual 语义(`W-tb-P9` 转接备忘的坑)。</lang>
|
|
@@ -17,11 +18,16 @@ import { tonalScale } from './color/scale.js';
|
|
|
17
18
|
import { cloneGradientSettings } from './data/gradients.js';
|
|
18
19
|
import { deriveThirdByRelation, getSeriesRelationDef } from './color/harmony.js';
|
|
19
20
|
// 由单个基色构建一个完整角色色:规范化色值、生成色阶并选择最佳前景色。
|
|
20
|
-
// <lang zh-CN>纯函数,无副作用;name
|
|
21
|
-
//
|
|
21
|
+
// <lang zh-CN>纯函数,无副作用;name 缺省时用 `nameColor` 的**真实色名**兜底(如"强蓝"),
|
|
22
|
+
// 而不是"主色"这类占位词——占位词会让 UI 显示"主色 #0047AB",用户仍不知道这是什么色。</lang>
|
|
23
|
+
// <lang en>Pure, side-effect-free. An empty name falls back to the **real** color name from `nameColor`
|
|
24
|
+
// (e.g. "Strong Blue") rather than a placeholder like "主色" — a placeholder leaves the UI showing
|
|
25
|
+
// "主色 #0047AB" without telling the user what color it actually is.</lang>
|
|
22
26
|
function buildRoleColor(value, name) {
|
|
23
27
|
const hex = normalizeHex(value);
|
|
24
|
-
|
|
28
|
+
// 色名兜底:`nameColor` 是纯函数(ISCC-NBS 修饰语 + 色相),对任意 HEX 都有结果。
|
|
29
|
+
// <lang en>The fallback is pure (ISCC-NBS modifier + hue) and defined for any HEX.</lang>
|
|
30
|
+
return { name: name || nameColor(hex).zh, value: hex, scale: tonalScale(hex), on: bestOnColor(hex).hex };
|
|
25
31
|
}
|
|
26
32
|
// 角色色深拷贝:阻断外部对象与内部状态的隐含耦合(scale 对象逐键复制)。
|
|
27
33
|
// <lang zh-CN>用于第三角色与辅助槽位入参与 Theme 装配的隔离。</lang>
|
|
@@ -46,17 +52,19 @@ export function buildTheme(input) {
|
|
|
46
52
|
// <lang zh-CN>主副色独立生成,保证各自色阶与前景色自洽;单色模式下副色取主色系变体(primary 深档,
|
|
47
53
|
// 定案:系统角色全链路照常,用户传入的 secondary 色相被变体替换)。</lang>
|
|
48
54
|
// <lang en>Single mode replaces the user secondary hue with the primary-series variant (primary 700 step) per the ADR-007 v2 decision.</lang>
|
|
49
|
-
|
|
55
|
+
// 不在此处用占位词兜底:空名称直接传给 buildRoleColor,由它用真实色名填充。
|
|
56
|
+
// <lang en>No placeholder here: an empty name reaches buildRoleColor, which fills in the real colour name.</lang>
|
|
57
|
+
const primary = buildRoleColor(input.primary, input.primaryName || '');
|
|
50
58
|
let secondary;
|
|
51
59
|
if (seriesMode === 'single') {
|
|
52
60
|
// 单色变体:取主色 700 档重建角色色(含色阶与前景色)。
|
|
53
61
|
// <lang zh-CN>primary.scale['700'] 为推导基准;name 标注变体来源。</lang>
|
|
54
62
|
// <lang en>Built from the primary 700 step with a variant name.</lang>
|
|
55
63
|
const variantHex = primary.scale['700'];
|
|
56
|
-
secondary = { name:
|
|
64
|
+
secondary = { name: (primary.name) + ' · 系列变体', value: variantHex, scale: tonalScale(variantHex), on: bestOnColor(variantHex).hex };
|
|
57
65
|
}
|
|
58
66
|
else {
|
|
59
|
-
secondary = buildRoleColor(input.secondary, input.secondaryName || '
|
|
67
|
+
secondary = buildRoleColor(input.secondary, input.secondaryName || '');
|
|
60
68
|
}
|
|
61
69
|
// 第三角色装配(ADR-007 v2):仅 triad 存在;显式入参深拷贝保留,缺省按关系规则从主色推导(manual/pure 无推导)。
|
|
62
70
|
// <lang zh-CN>推导语义:primary/secondary 为用户根基,第三色补全组合(可覆写)。</lang>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hia/theme-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "HIA cross-platform theme domain core: models, OKLCH algorithms, theme studio state, gradient rendering, token export and website-color analysis.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "HIA Theme Builder contributors",
|