Skip to content

Commit ecda398

Browse files
committed
updated system color table
1 parent 78ad259 commit ecda398

File tree

2 files changed

+183
-19
lines changed

2 files changed

+183
-19
lines changed

content/practices/color-settings/color-settings-practice.html

+72-13
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ <h3>Current Color vs. System Colors</h3>
868868
<p>System colors values should be used when the custom elements are built using elements whose current color does not match the semantics of the custom component and when <code>currentcolor</code> is insufficient for matching the styling needs of the component to make it's features discernible. Using System colors allows for setting both foreground and background colors and making features of the custom control identifiable. For example using <code>div</code> elements to build a custom slider component. If the <code>currentColor</code> value is used the <code>div</code> elements cause the features of the slider to be rendered using the <code>CanvasText</code> color, when the slider features should be rendered using <code>ButtonBorder</code>, <code>ButtonFace</code> and <code>ButtonText</code>. System Colors require using the <code>forced-colors: active</code> media query to ensure the system colors are only used to override the authors theme when the use renables a Contrast Theme.</p>
869869

870870
<table class="data">
871-
<caption>Summary of Current Color vs. System Color</caption>
871+
<caption>Summary of Current Color vs. System Color for Interactive Components</caption>
872872
<thead>
873873
<tr>
874874
<th style="width: 7em">Technique</th>
@@ -912,6 +912,58 @@ <h3>Current Color vs. System Colors</h3>
912912
</tbody>
913913
</table>
914914

915+
<h4 id="compare-switch-examples">Comparing Switch Examples</h4>
916+
917+
<p>The following tables describe the differences in the two switch examples using Current Color and System Colors.
918+
919+
920+
<table class="data">
921+
<caption>Switch Examples using Current Color and Systems Colors</caption>
922+
<thead>
923+
<tr>
924+
<th rowspan="2">Example</th>
925+
<th colspan="2">Span</th>
926+
<th colspan="2">SVG Rect</th>
927+
<th colspan="2">SVG Circle Off</th>
928+
<th colspan="2">SVG Circle On</th>
929+
</tr>
930+
<tr>
931+
<th>Background-Color</th>
932+
<th>Color</th>
933+
<th>Stroke</th>
934+
<th>Fill</th>
935+
<th>Stroke</th>
936+
<th>Fill</th>
937+
<th>Stroke</th>
938+
<th>Fill</th>
939+
</tr>
940+
</thead>
941+
<tbody>
942+
<tr>
943+
<td><code>button[role="switch"]</code></td>
944+
<td>Opacity 0</td>
945+
<td>CurrentColor</td>
946+
<td>Opacity 0</td>
947+
<td>CurrentColor</td>
948+
<td>CurrentColor</td>
949+
<td>CurrentColor</td>
950+
<td>CurrentColor</td>
951+
<td>CurrentColor</td>
952+
</tr>
953+
<tr>
954+
<td><code>div[role="switch"]</code></td>
955+
<td>ButtonFace</td>
956+
<td>ButtonText</td>
957+
<td>ButtonBorder</td>
958+
<td>ButtonFace</td>
959+
<td>ButtonText</td>
960+
<td>GrayText</td>
961+
<td>ButtonText</td>
962+
<td>ActiveText</td>
963+
</tr>
964+
</tbody>
965+
</table>
966+
915967

916968
<h3>Using Current Color</h3>
917969

@@ -1147,28 +1199,35 @@ <h3 id="using-system-colors">Using System Colors</h3>
11471199
</tbody>
11481200
</table>
11491201

1150-
<h3 id="computed-system-colors">Computed System Colors</h3>
1202+
<h3 id="computed-system-colors">System Color Support</h3>
11511203

1152-
<p>The following table identifies the current system colors defined in <a href="https://www.w3.org/TR/css-color-4/#css-system-colors">CSS Color Module Level 4</a>. System colors are supported in all major browsers, but the <strong>actual colors</strong> they render may vary between browsers and operating systems based on default and user theme and contrast settings.</p>
1204+
<p>The following table identifies the current system colors defined in <a href="https://www.w3.org/TR/css-color-4/#css-system-colors">CSS Color Module Level 4</a>. System colors are supported in all major browsers, but the default <strong>colors</strong> they render may vary between browsers and operating systems. When a user enables Contrast Themes not all system colors change to use one of the colors defined in the theme. The followin table identifies which system colors support a colors in a contrast theme. Fortunately for the supported, the system colors are consistently rendered between browsers.</p>
11531205

11541206
<table aria-labelledby="system-colors" class="data">
11551207
<thead>
11561208
<tr>
1157-
<th>System Color</th>
1158-
<th>Computed Sample</th>
1159-
<th style="min-width: 12em">Computed Color</th>
1160-
<th>Description</th>
1209+
<th rowspan="2">System Color</th>
1210+
<th rowspan="2">Contrast Theme Color</th>
1211+
<th colspan="2">Theme Support</th>
1212+
<th rowspan="2">Computed Sample</th>
1213+
<th rowspan="2">Description</th>
1214+
</tr>
1215+
<tr>
1216+
<th>Chromium</th>
1217+
<th>Mozilla</th>
11611218
</tr>
11621219
</thead>
1163-
<tbody id="samples">
1220+
<tbody id="system-colors">
11641221
</tbody>
11651222
</table>
11661223

1167-
<div class="support-notice">
1168-
<div class="caution"><strong>Caution:</strong>
1169-
The system colors <code>AccentColor</code> and <code>AccentColorText</code> are not supported by the Chrome browser and are not included in the preceding table. They should not be used since they will result in unpredictable color contrast.
1170-
</div>
1171-
</div>
1224+
<h3 id="system-colors">Supported System Colors in Contrast Themes</h3>
1225+
1226+
<p>The following list of colors are considered "safe" to use when a user enables a contrast theme. Safe colors are color that use one of the theme colors.</p>
1227+
1228+
<ul id="usable-system-colors">
1229+
</ul>
1230+
11721231

11731232
<h3 id="forced-colors-example-switch">System Color Example: Switch using <code>div[role="switch"]</code></h3>
11741233

content/practices/color-settings/js/color-settings-practice.js

+111-6
Original file line numberDiff line numberDiff line change
@@ -664,89 +664,156 @@ function getHTMLColorName(systemColorName, colorHex) {
664664
}
665665

666666
const systemColorValues = [
667+
{
668+
value: 'AccentColor',
669+
name: 'Accent Color',
670+
contrastTheme: '',
671+
chromium: false,
672+
mozilla: false,
673+
desc: 'Background of accented user interface controls.',
674+
},
675+
{
676+
value: 'AccentColorText',
677+
name: 'Accesnt Color Text',
678+
contrastTheme: '',
679+
chromium: false,
680+
mozilla: false,
681+
desc: 'Text of accented user interface controls.',
682+
},
667683
{
668684
value: 'ActiveText',
669685
name: 'Active text',
686+
contrastTheme: 'Hyperlink',
687+
chromium: true,
688+
mozilla: true,
670689
desc: 'Text of active links',
671690
},
672691
{
673692
value: 'ButtonBorder',
674693
name: 'Button border',
694+
contrastTheme: 'Button color',
695+
chromium: true,
696+
mozilla: true,
675697
desc: 'Base border color of controls',
676698
},
677699
{
678700
value: 'ButtonFace',
679701
name: 'Button face',
702+
contrastTheme: 'Button background',
703+
chromium: true,
704+
mozilla: true,
680705
desc: 'Background color of controls',
681706
},
682707
{
683708
value: 'ButtonText',
684709
name: 'Button text',
710+
contrastTheme: 'Button color',
711+
chromium: true,
712+
mozilla: true,
685713
desc: 'Text color of controls',
686714
},
687715
{
688716
value: 'Canvas',
689717
name: 'Canvas',
718+
contrastTheme: 'Background',
719+
chromium: true,
720+
mozilla: true,
690721
desc: 'Background of application content or documents',
691722
},
692723
{
693724
value: 'CanvasText',
694725
name: 'Canvas text',
726+
contrastTheme: 'Text',
727+
chromium: true,
728+
mozilla: true,
695729
desc: 'Text color in application content or documents',
696730
},
697731
{
698732
value: 'Field',
699733
name: 'Field',
734+
contrastTheme: 'Button text background',
735+
chromium: true,
736+
mozilla: true,
700737
desc: 'Background of input fields',
701738
},
702739
{
703740
value: 'FieldText',
704741
name: 'Field text',
742+
contrastTheme: 'Button text color',
743+
chromium: true,
744+
mozilla: true,
705745
desc: 'Text in input fields',
706746
},
707747
{
708748
value: 'GrayText',
709749
name: 'Gray text',
750+
contrastTheme: 'Inactive text',
751+
chromium: true,
752+
mozilla: true,
710753
desc: 'Text color for disabled items (e.g. a disabled control)',
711754
},
712755
{
713756
value: 'Highlight',
714757
name: 'Highlight',
758+
contrastTheme: 'Selected text background',
759+
chromium: true,
760+
mozilla: true,
715761
desc: 'Background of selected items',
716762
},
717763
{
718764
value: 'HighlightText',
719765
name: 'Highlight text',
766+
contrastTheme: 'Selected text',
767+
chromium: true,
768+
mozilla: true,
720769
desc: 'Text color of selected items',
721770
},
722771
{
723772
value: 'LinkText',
724773
name: 'Link text',
774+
contrastTheme: 'Hyperlink',
775+
chromium: true,
776+
mozilla: true,
725777
desc: 'Text of non-active, non-visited links',
726778
},
727779
{
728780
value: 'Mark',
729781
name: 'Mark',
782+
contrastTheme: '',
783+
chromium: false,
784+
mozilla: false,
730785
desc: 'Background of text that has been specially marked (such as by the HTML mark element)',
731786
},
732787
{
733788
value: 'MarkText',
734789
name: 'Mark text',
790+
contrastTheme: '',
791+
chromium: false,
792+
mozilla: false,
735793
desc: 'Text that has been specially marked (such as by the HTML mark element)',
736794
},
737795
{
738796
value: 'SelectedItem',
739797
name: 'Selected item',
798+
contrastTheme: 'Selected text background',
799+
chromium: false,
800+
mozilla: true,
740801
desc: 'Background of selected items, for example, a selected checkbox',
741802
},
742803
{
743804
value: 'SelectedItemText',
744805
name: 'Selected item text',
806+
contrastTheme: 'Selected text',
807+
chromium: false,
808+
mozilla: true,
745809
desc: 'Text of selected items',
746810
},
747811
{
748812
value: 'VisitedText',
749813
name: 'Visited text',
814+
contrastTheme: 'Hyperlink',
815+
chromium: true,
816+
mozilla: false,
750817
desc: 'Text of visited links',
751818
},
752819
];
@@ -795,14 +862,39 @@ function rgb2Hex(rgb) {
795862
// Fill in System color table
796863

797864
window.addEventListener('load', () => {
798-
const tbodyNode = document.getElementById('samples');
865+
const tbodyNode = document.getElementById('system-colors');
866+
const ulNode = document.getElementById('usable-system-colors');
867+
799868

800869
systemColorValues.forEach((v) => {
801870
if (v.value) {
871+
// System Color Name
802872
const tr = document.createElement('tr');
803873
const thv = document.createElement('th');
804874
thv.textContent = v.value;
805875
tr.appendChild(thv);
876+
877+
// Windows 11 Contrast Theme Value
878+
const tdct = document.createElement('td');
879+
tdct.textContent = v.contrastTheme;
880+
tr.appendChild(tdct);
881+
882+
// Chromium Support
883+
const tdchrome = document.createElement('td');
884+
v.chromium ?
885+
tdchrome.textContent = 'Yes' :
886+
tdchrome.textContent = '-';
887+
888+
tr.appendChild(tdchrome);
889+
890+
// Mozilla Support
891+
const tdmoz = document.createElement('td');
892+
v.mozilla ?
893+
tdmoz.textContent = 'Yes' :
894+
tdmoz.textContent = '-';
895+
tr.appendChild(tdmoz);
896+
897+
// Color Sample
806898
const tds = document.createElement('td');
807899
const div = document.createElement('div');
808900
div.role = 'img';
@@ -813,22 +905,35 @@ window.addEventListener('load', () => {
813905
divHex.className = 'color';
814906
tds.appendChild(divHex);
815907
tr.appendChild(tds);
816-
const tdRGB = document.createElement('td');
817-
tdRGB.className = 'font';
818-
tdRGB.textContent = '??';
819-
tr.appendChild(tdRGB);
908+
// const tdRGB = document.createElement('td');
909+
// tdRGB.className = 'font';
910+
// tdRGB.textContent = '??';
911+
// tr.appendChild(tdRGB);
820912
const tdHex = document.createElement('td');
821913
tdHex.className = 'font';
822914
tdHex.textContent = '??';
915+
916+
// System Color Description
823917
const tdd = document.createElement('td');
824918
tdd.textContent = v.desc;
825919
tr.appendChild(tdd);
920+
826921
tbodyNode.appendChild(tr);
827922
const cStyle = window.getComputedStyle(div);
828-
tdRGB.textContent = cStyle.backgroundColor;
923+
// tdRGB.textContent = cStyle.backgroundColor;
829924
const colorHex = rgb2Hex(cStyle.backgroundColor);
830925
divHex.textContent = colorHex;
831926
div.ariaLabel = getHTMLColorName(v.name, colorHex);
832927
}
928+
929+
// Usable colors list
930+
if (v.chromium && v.mozilla) {
931+
const liNode = document.createElement('li');
932+
const codeNode = document.createElement('code');
933+
codeNode.textContent = v.value;
934+
liNode.appendChild(codeNode);
935+
ulNode.appendChild(liNode);
936+
}
937+
833938
});
834939
});

0 commit comments

Comments
 (0)