Skip to content

Commit 2d22ffc

Browse files
authored
fix(theme): remove extra shade (950) from the color scales for consistency in dark mode (#199) (#200)
* fix(theme): remove extra key (950) from the color scales for consistency in dark mode * build(docs): explicitly set Tailwind v4.0.9
1 parent fbaea4a commit 2d22ffc

File tree

5 files changed

+187
-166
lines changed

5 files changed

+187
-166
lines changed

docs/LumexUI.Docs/LumexUI.Docs.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
<Target Name="InstallTailwindCSS" AfterTargets="Build" Condition="!Exists('tailwindcss.exe')">
2929
<PropertyGroup>
3030
<!-- Tailwind standalone CLI for Windows -->
31-
<TailwindURL Condition="'$(OS)' == 'Windows_NT'">https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-windows-x64.exe</TailwindURL>
31+
<TailwindURL Condition="'$(OS)' == 'Windows_NT'">https://github.com/tailwindlabs/tailwindcss/releases/download/v4.0.9/tailwindcss-windows-x64.exe</TailwindURL>
3232
<TailwindFile Condition="'$(OS)' == 'Windows_NT'">tailwindcss-windows-x64.exe</TailwindFile>
3333

3434
<!-- Tailwind standalone CLI for Linux -->
35-
<TailwindURL Condition="'$(OS)' != 'Windows_NT'">https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64</TailwindURL>
35+
<TailwindURL Condition="'$(OS)' != 'Windows_NT'">https://github.com/tailwindlabs/tailwindcss/releases/download/v4.0.9/tailwindcss-linux-x64</TailwindURL>
3636
<TailwindFile Condition="'$(OS)' != 'Windows_NT'">tailwindcss-linux-x64</TailwindFile>
3737
</PropertyGroup>
3838

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace LumexUI.Extensions;
4+
5+
[ExcludeFromCodeCoverage]
6+
internal static class DictionaryExtensions
7+
{
8+
public static Dictionary<TKey, TValue> TakeAllExceptLast<TKey, TValue>( this IReadOnlyDictionary<TKey, TValue> source, int count = 1 )
9+
where TKey : notnull
10+
{
11+
ArgumentNullException.ThrowIfNull( source, nameof( source ) );
12+
13+
if( count < 1 )
14+
{
15+
throw new ArgumentOutOfRangeException( nameof( count ), count, "The count must be greater than one." );
16+
}
17+
18+
if( count >= source.Count )
19+
{
20+
return [];
21+
}
22+
23+
return source
24+
.Take( source.Count - count )
25+
.ToDictionary( x => x.Key, x => x.Value );
26+
}
27+
}

src/LumexUI/Theme/Colors/SemanticColors.cs

Lines changed: 142 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// LumexUI licenses this file to you under the MIT license
33
// See the license here https://github.com/LumexUI/lumexui/blob/main/LICENSE
44

5+
using LumexUI.Extensions;
6+
57
using static LumexUI.Utilities.ColorUtils;
68

79
namespace LumexUI.Theme;
@@ -11,146 +13,146 @@ namespace LumexUI.Theme;
1113
/// </summary>
1214
public static class SemanticColors
1315
{
14-
private const string Default = "default";
15-
private const string Foreground = "foreground";
16+
private const string Default = "default";
17+
private const string Foreground = "foreground";
1618

17-
/// <summary>
18-
/// Represents the theme colors for the light theme.
19-
/// </summary>
20-
public readonly static ThemeColors Light = new()
21-
{
22-
Background = [
23-
new( Default, Colors.White )
24-
],
25-
Foreground = [
26-
.. Colors.Zinc,
27-
new( Default, Colors.Zinc["700"] ),
28-
],
29-
Overlay = [
30-
new( Default, Colors.Black )
31-
],
32-
Focus = [
33-
new( Default, Colors.Blue["500"] )
34-
],
35-
Divider = [
36-
new( Default, Colors.Zinc["900"] )
37-
],
38-
Surface1 = [
39-
new( Default, Colors.White ),
40-
new( Foreground, Colors.Zinc["900"] )
41-
],
42-
Surface2 = [
43-
new( Default, Colors.Zinc["100"] ),
44-
new( Foreground, Colors.Zinc["800"] )
45-
],
46-
Surface3 = [
47-
new( Default, Colors.Zinc["200"] ),
48-
new( Foreground, Colors.Zinc["700"] )
49-
],
50-
Default = [
51-
.. Colors.Zinc,
52-
new( Default, Colors.Zinc["300"] ),
53-
new( Foreground, GetReadableColor( Colors.Zinc["300"] ) )
54-
],
55-
Primary = [
56-
.. Colors.Blue,
57-
new( Default, Colors.Blue["500"] ),
58-
new( Foreground, GetReadableColor( Colors.Blue["500"] ) )
59-
],
60-
Secondary = [
61-
.. Colors.Violet,
62-
new( Default, Colors.Violet["500"] ),
63-
new( Foreground, GetReadableColor( Colors.Violet["500"] ) )
64-
],
65-
Success = [
66-
.. Colors.Green,
67-
new( Default, Colors.Green["500"] ),
68-
new( Foreground, GetReadableColor( Colors.Green["500"] ) )
69-
],
70-
Warning = [
71-
.. Colors.Amber,
72-
new( Default, Colors.Amber["500"] ),
73-
new( Foreground, GetReadableColor( Colors.Amber["500"] ) )
74-
],
75-
Danger = [
76-
.. Colors.Rose,
77-
new( Default, Colors.Rose["500"] ),
78-
new( Foreground, GetReadableColor( Colors.Rose["500"] ) )
79-
],
80-
Info = [
81-
.. Colors.Sky,
82-
new( Default, Colors.Sky["500"] ),
83-
new( Foreground, GetReadableColor( Colors.Sky["500"] ) )
84-
]
85-
};
19+
/// <summary>
20+
/// Represents the theme colors for the light theme.
21+
/// </summary>
22+
public readonly static ThemeColors Light = new()
23+
{
24+
Background = [
25+
new( Default, Colors.White )
26+
],
27+
Foreground = [
28+
.. Colors.Zinc.TakeAllExceptLast(),
29+
new( Default, Colors.Zinc["700"] ),
30+
],
31+
Overlay = [
32+
new( Default, Colors.Black )
33+
],
34+
Focus = [
35+
new( Default, Colors.Blue["500"] )
36+
],
37+
Divider = [
38+
new( Default, Colors.Zinc["900"] )
39+
],
40+
Surface1 = [
41+
new( Default, Colors.White ),
42+
new( Foreground, Colors.Zinc["900"] )
43+
],
44+
Surface2 = [
45+
new( Default, Colors.Zinc["100"] ),
46+
new( Foreground, Colors.Zinc["800"] )
47+
],
48+
Surface3 = [
49+
new( Default, Colors.Zinc["200"] ),
50+
new( Foreground, Colors.Zinc["700"] )
51+
],
52+
Default = [
53+
.. Colors.Zinc.TakeAllExceptLast(),
54+
new( Default, Colors.Zinc["300"] ),
55+
new( Foreground, GetReadableColor( Colors.Zinc["300"] ) )
56+
],
57+
Primary = [
58+
.. Colors.Blue.TakeAllExceptLast(),
59+
new( Default, Colors.Blue["500"] ),
60+
new( Foreground, GetReadableColor( Colors.Blue["500"] ) )
61+
],
62+
Secondary = [
63+
.. Colors.Violet.TakeAllExceptLast(),
64+
new( Default, Colors.Violet["500"] ),
65+
new( Foreground, GetReadableColor( Colors.Violet["500"] ) )
66+
],
67+
Success = [
68+
.. Colors.Green.TakeAllExceptLast(),
69+
new( Default, Colors.Green["500"] ),
70+
new( Foreground, GetReadableColor( Colors.Green["500"] ) )
71+
],
72+
Warning = [
73+
.. Colors.Amber.TakeAllExceptLast(),
74+
new( Default, Colors.Amber["500"] ),
75+
new( Foreground, GetReadableColor( Colors.Amber["500"] ) )
76+
],
77+
Danger = [
78+
.. Colors.Rose.TakeAllExceptLast(),
79+
new( Default, Colors.Rose["500"] ),
80+
new( Foreground, GetReadableColor( Colors.Rose["500"] ) )
81+
],
82+
Info = [
83+
.. Colors.Sky.TakeAllExceptLast(),
84+
new( Default, Colors.Sky["500"] ),
85+
new( Foreground, GetReadableColor( Colors.Sky["500"] ) )
86+
]
87+
};
8688

87-
/// <summary>
88-
/// Represents the theme colors for the dark theme.
89-
/// </summary>
90-
public readonly static ThemeColors Dark = new()
91-
{
92-
Background = [
93-
new( Default, Colors.Black )
94-
],
95-
Foreground = [
96-
.. Colors.ReverseColorValues( Colors.Zinc ),
97-
new( Default, Colors.Zinc["200"] ),
98-
],
99-
Overlay = [
100-
new( Default, Colors.Black )
101-
],
102-
Focus = [
103-
new( Default, Colors.Blue["500"] )
104-
],
105-
Divider = [
106-
new( Default, Colors.Zinc["50"] )
107-
],
108-
Surface1 = [
109-
new( Default, Colors.Zinc["900"] ),
110-
new( Foreground, Colors.Zinc["50"] )
111-
],
112-
Surface2 = [
113-
new( Default, Colors.Zinc["800"] ),
114-
new( Foreground, Colors.Zinc["100"] )
115-
],
116-
Surface3 = [
117-
new( Default, Colors.Zinc["700"] ),
118-
new( Foreground, Colors.Zinc["200"] )
119-
],
120-
Default = [
121-
.. Colors.ReverseColorValues( Colors.Zinc ),
122-
new( Default, Colors.Zinc["300"] ),
123-
new( Foreground, GetReadableColor( Colors.Zinc["300"] ) )
124-
],
125-
Primary = [
126-
.. Colors.ReverseColorValues( Colors.Blue ),
127-
new( Default, Colors.Blue["500"] ),
128-
new( Foreground, GetReadableColor( Colors.Blue["500"] ) )
129-
],
130-
Secondary = [
131-
.. Colors.ReverseColorValues( Colors.Violet ),
132-
new( Default, Colors.Violet["500"] ),
133-
new( Foreground, GetReadableColor( Colors.Violet["500"] ) )
134-
],
135-
Success = [
136-
.. Colors.ReverseColorValues( Colors.Green ),
137-
new( Default, Colors.Green["500"] ),
138-
new( Foreground, GetReadableColor( Colors.Green["500"] ) )
139-
],
140-
Warning = [
141-
.. Colors.ReverseColorValues( Colors.Amber ),
142-
new( Default, Colors.Amber["500"] ),
143-
new( Foreground, GetReadableColor( Colors.Amber["500"] ) )
144-
],
145-
Danger = [
146-
.. Colors.ReverseColorValues( Colors.Rose ),
147-
new( Default, Colors.Rose["500"] ),
148-
new( Foreground, GetReadableColor( Colors.Rose["500"] ) )
149-
],
150-
Info = [
151-
.. Colors.ReverseColorValues( Colors.Sky ),
152-
new( Default, Colors.Sky["500"] ),
153-
new( Foreground, GetReadableColor( Colors.Sky["500"] ) )
154-
]
155-
};
89+
/// <summary>
90+
/// Represents the theme colors for the dark theme.
91+
/// </summary>
92+
public readonly static ThemeColors Dark = new()
93+
{
94+
Background = [
95+
new( Default, Colors.Black )
96+
],
97+
Foreground = [
98+
.. Colors.ReverseColorValues( Colors.Zinc.TakeAllExceptLast() ),
99+
new( Default, Colors.Zinc["200"] ),
100+
],
101+
Overlay = [
102+
new( Default, Colors.Black )
103+
],
104+
Focus = [
105+
new( Default, Colors.Blue["500"] )
106+
],
107+
Divider = [
108+
new( Default, Colors.Zinc["50"] )
109+
],
110+
Surface1 = [
111+
new( Default, Colors.Zinc["900"] ),
112+
new( Foreground, Colors.Zinc["50"] )
113+
],
114+
Surface2 = [
115+
new( Default, Colors.Zinc["800"] ),
116+
new( Foreground, Colors.Zinc["100"] )
117+
],
118+
Surface3 = [
119+
new( Default, Colors.Zinc["700"] ),
120+
new( Foreground, Colors.Zinc["200"] )
121+
],
122+
Default = [
123+
.. Colors.ReverseColorValues( Colors.Zinc.TakeAllExceptLast() ),
124+
new( Default, Colors.Zinc["300"] ),
125+
new( Foreground, GetReadableColor( Colors.Zinc["300"] ) )
126+
],
127+
Primary = [
128+
.. Colors.ReverseColorValues( Colors.Blue.TakeAllExceptLast() ),
129+
new( Default, Colors.Blue["500"] ),
130+
new( Foreground, GetReadableColor( Colors.Blue["500"] ) )
131+
],
132+
Secondary = [
133+
.. Colors.ReverseColorValues( Colors.Violet.TakeAllExceptLast() ),
134+
new( Default, Colors.Violet["500"] ),
135+
new( Foreground, GetReadableColor( Colors.Violet["500"] ) )
136+
],
137+
Success = [
138+
.. Colors.ReverseColorValues( Colors.Green.TakeAllExceptLast() ),
139+
new( Default, Colors.Green["500"] ),
140+
new( Foreground, GetReadableColor( Colors.Green["500"] ) )
141+
],
142+
Warning = [
143+
.. Colors.ReverseColorValues( Colors.Amber.TakeAllExceptLast() ),
144+
new( Default, Colors.Amber["500"] ),
145+
new( Foreground, GetReadableColor( Colors.Amber["500"] ) )
146+
],
147+
Danger = [
148+
.. Colors.ReverseColorValues( Colors.Rose.TakeAllExceptLast() ),
149+
new( Default, Colors.Rose["500"] ),
150+
new( Foreground, GetReadableColor( Colors.Rose["500"] ) )
151+
],
152+
Info = [
153+
.. Colors.ReverseColorValues( Colors.Sky.TakeAllExceptLast() ),
154+
new( Default, Colors.Sky["500"] ),
155+
new( Foreground, GetReadableColor( Colors.Sky["500"] ) )
156+
]
157+
};
156158
}

0 commit comments

Comments
 (0)