Skip to content

Commit b6091d6

Browse files
committed
Merge branch 'main' of https://github.com/coreui/coreui
# Conflicts: # package-lock.json
2 parents 86372bc + a658bc5 commit b6091d6

File tree

8 files changed

+900
-349
lines changed

8 files changed

+900
-349
lines changed

package-lock.json

Lines changed: 732 additions & 333 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,21 @@
9898
"@babel/core": "^7.28.3",
9999
"@babel/preset-env": "^7.28.3",
100100
"@docsearch/js": "^3.9.0",
101-
"@eslint/markdown": "^7.1.0",
101+
"@eslint/markdown": "^7.2.0",
102102
"@popperjs/core": "^2.11.8",
103103
"@rollup/plugin-babel": "^6.0.4",
104104
"@rollup/plugin-commonjs": "^28.0.6",
105105
"@rollup/plugin-node-resolve": "^16.0.1",
106106
"@rollup/plugin-replace": "^6.0.2",
107107
"@stackblitz/sdk": "^1.11.0",
108108
"autoprefixer": "^10.4.21",
109-
"bootstrap": "^5.3.7",
109+
"bootstrap": "^5.3.8",
110110
"bundlewatch": "^0.4.1",
111111
"clean-css-cli": "^5.6.3",
112112
"clipboard": "^2.0.11",
113113
"cross-env": "^10.0.0",
114-
"eslint": "^9.33.0",
115-
"eslint-config-xo": "0.48.0",
114+
"eslint": "^9.34.0",
115+
"eslint-config-xo": "0.49.0",
116116
"eslint-plugin-html": "^8.1.3",
117117
"eslint-plugin-import": "^2.32.0",
118118
"eslint-plugin-unicorn": "^60.0.0",
@@ -121,9 +121,9 @@
121121
"globby": "^14.1.0",
122122
"hammer-simulator": "0.0.1",
123123
"html-entities": "^2.6.0",
124-
"hugo-bin": "^0.145.2",
124+
"hugo-bin": "^0.146.0",
125125
"ip": "^2.0.1",
126-
"jasmine": "^5.9.0",
126+
"jasmine": "^5.10.0",
127127
"jquery": "^3.7.1",
128128
"karma": "^6.4.4",
129129
"karma-browserstack-launcher": "1.6.0",
@@ -140,9 +140,9 @@
140140
"postcss": "^8.5.6",
141141
"postcss-cli": "^11.0.1",
142142
"postcss-combine-duplicated-selectors": "^10.0.3",
143-
"rollup": "^4.46.2",
143+
"rollup": "^4.50.0",
144144
"rollup-plugin-istanbul": "^5.0.0",
145-
"sass-embedded": "^1.90.0",
145+
"sass-embedded": "^1.91.0",
146146
"sass-true": "^9.0.0",
147147
"shelljs": "^0.10.0",
148148
"stylelint": "^16.23.1",

scss/_reboot.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ legend {
537537
[type="search"] {
538538
-webkit-appearance: textfield; // 1
539539
outline-offset: -2px; // 2
540+
541+
// 3. Better affordance and consistent appearance for search cancel button
542+
&::-webkit-search-cancel-button {
543+
cursor: pointer;
544+
filter: grayscale(1);
545+
}
540546
}
541547

542548
// 1. A few input types should stay LTR

scss/_spinners.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
.spinner-grow,
88
.spinner-border {
99
display: inline-block;
10+
flex-shrink: 0;
1011
width: var(--#{$prefix}spinner-width);
1112
height: var(--#{$prefix}spinner-height);
1213
vertical-align: var(--#{$prefix}spinner-vertical-align);

scss/functions/_color-contrast-variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@each $color in $foregrounds {
1111
$contrast-ratio: contrast-ratio($background, $color);
12-
@if $contrast-ratio > $min-contrast-ratio {
12+
@if $contrast-ratio >= $min-contrast-ratio {
1313
@return $color;
1414
} @else if $contrast-ratio > $max-ratio {
1515
$max-ratio: $contrast-ratio;

scss/functions/_color-contrast.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@each $color in $foregrounds {
1414
$contrast-ratio: contrast-ratio($background, $color);
15-
@if $contrast-ratio > $min-contrast-ratio {
15+
@if $contrast-ratio >= $min-contrast-ratio {
1616
@return $color;
1717
} @else if $contrast-ratio > $max-ratio {
1818
$max-ratio: $contrast-ratio;

scss/functions/_contrast-ratio.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
@use "sass:color";
2+
@use "sass:list";
23
@use "sass:map";
34
@use "sass:math";
4-
@use "math" as *;
5+
6+
// A list of pre-calculated numbers of pow(divide((divide($value, 255) + .055), 1.055), 2.4). (from 0 to 255)
7+
// stylelint-disable-next-line scss/dollar-variable-default, scss/dollar-variable-pattern
8+
$_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003 .0033 .0037 .004 .0044 .0048 .0052 .0056 .006 .0065 .007 .0075 .008 .0086 .0091 .0097 .0103 .011 .0116 .0123 .013 .0137 .0144 .0152 .016 .0168 .0176 .0185 .0194 .0203 .0212 .0222 .0232 .0242 .0252 .0262 .0273 .0284 .0296 .0307 .0319 .0331 .0343 .0356 .0369 .0382 .0395 .0409 .0423 .0437 .0452 .0467 .0482 .0497 .0513 .0529 .0545 .0561 .0578 .0595 .0612 .063 .0648 .0666 .0685 .0704 .0723 .0742 .0762 .0782 .0802 .0823 .0844 .0865 .0887 .0908 .0931 .0953 .0976 .0999 .1022 .1046 .107 .1095 .1119 .1144 .117 .1195 .1221 .1248 .1274 .1301 .1329 .1356 .1384 .1413 .1441 .147 .15 .1529 .1559 .159 .162 .1651 .1683 .1714 .1746 .1779 .1812 .1845 .1878 .1912 .1946 .1981 .2016 .2051 .2086 .2122 .2159 .2195 .2232 .227 .2307 .2346 .2384 .2423 .2462 .2502 .2542 .2582 .2623 .2664 .2705 .2747 .2789 .2831 .2874 .2918 .2961 .3005 .305 .3095 .314 .3185 .3231 .3278 .3325 .3372 .3419 .3467 .3515 .3564 .3613 .3663 .3712 .3763 .3813 .3864 .3916 .3968 .402 .4072 .4125 .4179 .4233 .4287 .4342 .4397 .4452 .4508 .4564 .4621 .4678 .4735 .4793 .4851 .491 .4969 .5029 .5089 .5149 .521 .5271 .5333 .5395 .5457 .552 .5583 .5647 .5711 .5776 .5841 .5906 .5972 .6038 .6105 .6172 .624 .6308 .6376 .6445 .6514 .6584 .6654 .6724 .6795 .6867 .6939 .7011 .7084 .7157 .7231 .7305 .7379 .7454 .7529 .7605 .7682 .7758 .7835 .7913 .7991 .807 .8148 .8228 .8308 .8388 .8469 .855 .8632 .8714 .8796 .8879 .8963 .9047 .9131 .9216 .9301 .9387 .9473 .956 .9647 .9734 .9823 .9911 1;
59

610
@function contrast-ratio($background, $foreground) {
711
$l1: luminance($background);
812
$l2: luminance(opaque($background, $foreground));
913

10-
@return if($l1 > $l2, divide($l1 + .05, $l2 + .05), divide($l2 + .05, $l1 + .05));
14+
@return if($l1 > $l2, math.div($l1 + .05, $l2 + .05), math.div($l2 + .05, $l1 + .05));
1115
}
1216

1317
// Return WCAG2.2 relative luminance
1418
// See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
1519
// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
1620
@function luminance($color) {
1721
$rgb: (
18-
"r": color.channel($color, "red", $space: rgb), // stylelint-disable-line scss/at-function-named-arguments
19-
"g": color.channel($color, "green", $space: rgb), // stylelint-disable-line scss/at-function-named-arguments
20-
"b": color.channel($color, "blue", $space: rgb) // stylelint-disable-line scss/at-function-named-arguments
22+
"r": color.channel($color, "red"),
23+
"g": color.channel($color, "green"),
24+
"b": color.channel($color, "blue")
2125
);
2226

2327
@each $name, $value in $rgb {
24-
$value: if(divide($value, 255) < .04045, divide(divide($value, 255), 12.92), math.pow(divide((divide(math.round($value) + 1, 255) + .055), 1.055), 2.4));
28+
$value: if(math.div($value, 255) < .04045, math.div(math.div($value, 255), 12.92), list.nth($_luminance-list, math.round($value + 1)));
2529
$rgb: map.merge($rgb, ($name: $value));
2630
}
2731

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
@use "../../functions/color-contrast" as *;
2+
@use "../../functions/contrast-ratio" as *;
3+
@use "../../variables" as *;
4+
@use "../../maps" as *;
5+
@use "../../mixins" as *;
6+
7+
$black: #000;
8+
9+
@include describe("color-contrast function") {
10+
@include it("should return a color when contrast ratio equals minimum requirement (WCAG 2.1 compliance)") {
11+
// Test case: Background color that produces contrast ratio close to 4.5:1
12+
// This tests the WCAG 2.1 requirement that contrast should be "at least 4.5:1" (>= 4.5)
13+
// rather than "strictly greater than 4.5:1" (> 4.5)
14+
15+
// #777777 produces 4.4776:1 contrast ratio with white text
16+
// Since this is below the 4.5:1 threshold, it should return the highest available contrast color
17+
$test-background: #777;
18+
$result: color-contrast($test-background);
19+
20+
@include assert-equal($result, $black, "Should return black (highest available contrast) for background with 4.4776:1 contrast ratio (below threshold)");
21+
}
22+
23+
@include it("should return a color when contrast ratio is above minimum requirement") {
24+
// Test case: Background color that produces contrast ratio above 4.5:1
25+
// #767676 produces 4.5415:1 contrast ratio with white text
26+
$test-background: #767676;
27+
$result: color-contrast($test-background);
28+
29+
@include assert-equal($result, $white, "Should return white for background with 4.5415:1 contrast ratio (above threshold)");
30+
}
31+
32+
@include it("should return a color when contrast ratio is below minimum requirement") {
33+
// Test case: Background color that produces contrast ratio below 4.5:1
34+
// #787878 produces 4.4155:1 contrast ratio with white text
35+
$test-background: #787878;
36+
$result: color-contrast($test-background);
37+
38+
// Should return the color with the highest available contrast ratio
39+
@include assert-equal($result, $black, "Should return black (highest available contrast) for background with 4.4155:1 contrast ratio (below threshold)");
40+
}
41+
42+
@include it("should handle edge case with very light background") {
43+
// Test case: Very light background that should return dark text
44+
$test-background: #f8f9fa; // Very light gray
45+
$result: color-contrast($test-background);
46+
47+
@include assert-equal($result, $color-contrast-dark, "Should return dark text for very light background");
48+
}
49+
50+
@include it("should handle edge case with very dark background") {
51+
// Test case: Very dark background that should return light text
52+
$test-background: #212529; // Very dark gray
53+
$result: color-contrast($test-background);
54+
55+
@include assert-equal($result, $color-contrast-light, "Should return light text for very dark background");
56+
}
57+
58+
@include it("should work with custom minimum contrast ratio") {
59+
// Test case: Using a custom minimum contrast ratio
60+
$test-background: #666;
61+
$result: color-contrast($test-background, $color-contrast-dark, $color-contrast-light, 3);
62+
63+
@include assert-equal($result, $white, "Should return white when using custom minimum contrast ratio of 3.0");
64+
}
65+
66+
@include it("should test contrast ratio calculation accuracy") {
67+
// Test case: Verify that contrast-ratio function works correctly
68+
$background: #767676;
69+
$foreground: $white;
70+
$ratio: contrast-ratio($background, $foreground);
71+
// Bootstrap's implementation calculates this as ~4.5415, not exactly 4.5, due to its luminance math.
72+
// We use 4.54 as the threshold for this test to match the actual implementation.
73+
@include assert-true($ratio >= 4.54 and $ratio <= 4.55, "Contrast ratio should be approximately 4.54:1 (Bootstrap's math)");
74+
}
75+
76+
@include it("should test luminance calculation") {
77+
// Test case: Verify luminance function works correctly
78+
$white-luminance: luminance($white);
79+
$black-luminance: luminance($black);
80+
81+
@include assert-equal($white-luminance, 1, "White should have luminance of 1");
82+
@include assert-equal($black-luminance, 0, "Black should have luminance of 0");
83+
}
84+
85+
@include it("should handle rgba colors correctly") {
86+
// Test case: Test with rgba colors
87+
$test-background: rgba(118, 118, 118, 1); // Same as #767676
88+
$result: color-contrast($test-background);
89+
90+
@include assert-equal($result, $white, "Should handle rgba colors correctly");
91+
}
92+
93+
@include it("should test the WCAG 2.1 boundary condition with color below threshold") {
94+
// Test case: Background color that produces contrast ratio below 4.5:1
95+
// #787878 produces 4.4155:1 contrast ratio with white
96+
$test-background: #787878; // Produces 4.4155:1 contrast ratio
97+
$contrast-ratio: contrast-ratio($test-background, $white);
98+
99+
// Verify the contrast ratio is below 4.5:1
100+
@include assert-true($contrast-ratio < 4.5, "Contrast ratio should be below 4.5:1 threshold");
101+
102+
// The color-contrast function should return the color with highest available contrast
103+
$result: color-contrast($test-background);
104+
@include assert-equal($result, $black, "color-contrast should return black (highest available contrast) for below-threshold ratio");
105+
}
106+
107+
@include it("should test the WCAG 2.1 boundary condition with color at threshold") {
108+
// Test case: Background color that produces contrast ratio close to 4.5:1
109+
// #777777 produces 4.4776:1 contrast ratio with white
110+
$test-background: #777; // Produces 4.4776:1 contrast ratio
111+
$contrast-ratio: contrast-ratio($test-background, $white);
112+
113+
// Verify the contrast ratio is below 4.5:1 threshold
114+
@include assert-true($contrast-ratio < 4.5, "Contrast ratio is below threshold, function should handle gracefully");
115+
}
116+
117+
@include it("should demonstrate the difference between > and >= operators") {
118+
// Test case: Demonstrates the difference between > and >= operators
119+
// Uses #767676 with a custom minimum contrast ratio that matches its actual ratio (4.5415)
120+
// With > 4.5415: should return black (fallback to highest available)
121+
// With >= 4.5415: should return white (meets threshold)
122+
123+
$test-background: #767676; // Produces 4.5415:1 contrast ratio
124+
$actual-ratio: contrast-ratio($test-background, $white);
125+
126+
// Test with a custom minimum that matches the actual ratio
127+
$result: color-contrast($test-background, $color-contrast-dark, $color-contrast-light, $actual-ratio);
128+
129+
// Should return white when using >= implementation
130+
@include assert-equal($result, $white, "color-contrast should return white when using exact ratio as threshold (>= implementation)");
131+
}
132+
133+
@include it("should test additional working colors above threshold") {
134+
// Test case: Background color that produces contrast ratio well above 4.5:1
135+
// #757575 produces 4.6047:1 contrast ratio with white text
136+
$test-background: #757575; // Produces 4.6047:1 contrast ratio
137+
$result: color-contrast($test-background);
138+
139+
@include assert-equal($result, $white, "Should return white for background with 4.6047:1 contrast ratio (well above threshold)");
140+
}
141+
}

0 commit comments

Comments
 (0)