Skip to content

Commit 148aa7d

Browse files
musaleMnickii
andauthored
Enable viewing the storybook and components in high contrast modes (#1623)
* Change from png to svg files for gh, npm icons * Update icons for components for higher contrast * Remove github and npm svg for manual creation * Make changes for storybook high contrast mode * Add stricter fill options for svg icons * Changes to set svg caret via js * Update borders for tabs, graff alt txt and scrollbar * Delete the right.svg file Unnecessary for this solution. * Remove <title> tag from svg to avoid double narration * Add support for desert contrast Co-authored-by: Nickii Miaro <miaronkirote@gmail.com>
1 parent 972e18d commit 148aa7d

File tree

13 files changed

+321
-13
lines changed

13 files changed

+321
-13
lines changed

.storybook/addons/codeEditorAddon/editor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ export class EditorElement extends LitElement {
4646
cursor: pointer;
4747
user-select: none;
4848
margin: 0px -2px 0px 0px;
49+
border: 1px solid transparent;
4950
}
5051
5152
.tab.selected {
5253
background-color: white;
5354
color: rgb(51, 51, 51);
5455
font-weight: 400;
56+
border: 2px solid transparent;
5557
}
5658
`;
5759
}

.storybook/manager-head.html

Lines changed: 102 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<script src="https://consentdeliveryfd.azurefd.net/mscc/lib/v2/wcp-consent.js"></script>
1515
<script src="https://az725175.vo.msecnd.net/scripts/jsll-4.js" type="text/javascript"></script>
1616
<script type="text/javascript">
17+
const xmlns = "http://www.w3.org/2000/svg";
18+
1719
var config = {
1820
autoCapture: {
1921
lineage: true
@@ -31,7 +33,6 @@
3133

3234
function addUsefulLinks() {
3335
const linkStyle = 'color: black; text-decoration: none; text-align: center; cursor: pointer; padding-right: 0.5rem;';
34-
const imageStyle = 'height: 0.75rem; margin-top: 0.125rem;';
3536
const textStyle = 'margin-left: 0.25rem; font-size: 0.75rem;';
3637
const linkContentStyle = 'display: flex;';
3738

@@ -49,19 +50,17 @@
4950

5051
const sidebarNode = sidebarHeader[0].parentNode;
5152

52-
// GitHub
53-
const githubImage = document.createElement('img');
54-
githubImage.src = './github.png';
55-
githubImage.alt = 'GitHub';
56-
githubImage.style = imageStyle;
53+
// Github
54+
const ghSvgPath = "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12";
55+
const githubSvgElem = createSvg(ghSvgPath);
5756

5857
const githubText = document.createElement('span');
5958
githubText.style = textStyle;
6059
githubText.innerText = 'GitHub';
6160

6261
const repoLinkContent = document.createElement('span');
6362
repoLinkContent.style = linkContentStyle;
64-
repoLinkContent.append(githubImage, githubText);
63+
repoLinkContent.append(githubSvgElem, githubText);
6564

6665
const repoLink = document.createElement('a');
6766
repoLink.href = 'https://aka.ms/mgt';
@@ -70,18 +69,16 @@
7069
repoLink.appendChild(repoLinkContent);
7170

7271
// npm
73-
const npmImage = document.createElement('img');
74-
npmImage.src = './npm.png';
75-
npmImage.alt = 'npm';
76-
npmImage.style = imageStyle;
72+
const npmSvgPath = "M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z";
73+
const npmSvgElem = createSvg(npmSvgPath);
7774

7875
const npmText = document.createElement('span');
7976
npmText.style = textStyle;
8077
npmText.innerText = 'npm';
8178

8279
const npmLinkContent = document.createElement('span');
8380
npmLinkContent.style = linkContentStyle;
84-
npmLinkContent.append(npmImage, npmText);
81+
npmLinkContent.append(npmSvgElem, npmText);
8582

8683
const npmLink = document.createElement('a');
8784
npmLink.href = 'https://www.npmjs.com/package/@microsoft/mgt';
@@ -156,6 +153,23 @@
156153
setListItemsAc11y();
157154
}
158155

156+
function createSvg(svgPath) {
157+
const boxWidth = 12;
158+
const boxHeight = 12;
159+
const imageStyle = 'height: 0.75rem; margin-top: 0.125rem;';
160+
const svgElem = document.createElementNS(xmlns, "svg");
161+
svgElem.setAttributeNS(null, "viewBox", `0 0 ${boxWidth * 2} ${boxHeight * 2}`);
162+
svgElem.setAttributeNS(null, "width", boxWidth);
163+
svgElem.setAttributeNS(null, "height", boxHeight);
164+
svgElem.setAttributeNS(null, "role", "image");
165+
svgElem.setAttributeNS(null, "style", imageStyle);
166+
167+
const svgElemPath = document.createElementNS(xmlns, "path");
168+
svgElemPath.setAttributeNS(null, "d", svgPath);
169+
170+
svgElem.appendChild(svgElemPath);
171+
return svgElem;
172+
}
159173
const windowWidth = window.innerWidth;
160174
// Whenever the browser zoom is added or reduced, as long as it's
161175
// over 100%, then get the footer height and set that as the value
@@ -224,6 +238,82 @@
224238
updateOnOrientationChange();
225239
</script>
226240

241+
<style>
242+
.css-bt79wf>svg>path,
243+
.css-1j9r8vi>svg>path {
244+
color: rgba(153, 153, 153, 0.6) !important;
245+
fill: rgba(153, 153, 153, 0.6) !important;
246+
}
247+
248+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
249+
#root,
250+
svg,
251+
svg>path,
252+
button {
253+
fill: rgb(255, 255, 255) !important;
254+
color: rgb(255, 255, 255) !important;
255+
}
256+
257+
.css-bt79wf>svg>path,
258+
.css-1j9r8vi>svg>path {
259+
color: rgba(255, 255, 255) !important;
260+
fill: rgba(255, 255, 255) !important;
261+
}
262+
263+
.css-cwrfva:hover,
264+
.css-cwrfva:focus-visible {
265+
border: 1px solid rgba(255, 255, 255) !important;
266+
}
267+
268+
.css-128qwy8:hover {
269+
/* background-image: radial-gradient(at center center,rgba(0,0,0,0.2) 0%,transparent 70%,transparent 100%); */
270+
background-image: radial-gradient(at center center, rgba(255, 255, 255) 100%, transparent 100%, transparent 100%);
271+
background-size: 50px 100%;
272+
background-position: 0 50%;
273+
background-repeat: no-repeat;
274+
}
275+
276+
.os-scrollbar>.os-scrollbar-track>.os-scrollbar-handle,
277+
.os-scrollbar>.os-scrollbar-track {
278+
border: 1px solid transparent;
279+
}
280+
}
281+
282+
@media (forced-colors: active) and (prefers-color-scheme: light) {
283+
#root,
284+
svg,
285+
svg>path,
286+
button {
287+
fill: rgb(0, 0, 0) !important;
288+
color: rgb(0, 0, 0) !important;
289+
}
290+
291+
.css-bt79wf>svg>path,
292+
.css-1j9r8vi>svg>path {
293+
color: rgba(0, 0, 0) !important;
294+
fill: rgba(0, 0, 0) !important;
295+
}
296+
297+
.css-cwrfva:hover,
298+
.css-cwrfva:focus-visible {
299+
border: 1px solid rgba(0, 0, 0) !important;
300+
}
301+
302+
.css-128qwy8:hover {
303+
/* background-image: radial-gradient(at center center,rgba(0,0,0,0.2) 0%,transparent 70%,transparent 100%); */
304+
background-image: radial-gradient(at center center, rgba(0, 0, 0, 0.2) 100%, transparent 100%, transparent 100%);
305+
background-size: 50px 100%;
306+
background-position: 0 50%;
307+
background-repeat: no-repeat;
308+
}
309+
310+
.os-scrollbar>.os-scrollbar-track>.os-scrollbar-handle,
311+
.os-scrollbar>.os-scrollbar-track {
312+
border: 1px solid transparent;
313+
}
314+
}
315+
</style>
316+
227317
<style>
228318
/* this keeps the storybook body area above footer */
229319
#root>div:first-of-type {

assets/github.png

-7.6 KB
Binary file not shown.

assets/npm.png

-200 Bytes
Binary file not shown.

packages/mgt-components/src/components/mgt-agenda/mgt-agenda.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,22 @@ mgt-agenda .event-attendee-loading {
185185
}
186186
}
187187
}
188+
189+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
190+
svg,
191+
svg > path {
192+
fill: rgb(255, 255, 255) !important;
193+
fill-rule: nonzero !important;
194+
clip-rule: nonzero !important;
195+
color: rgb(255, 255, 255) !important;
196+
}
197+
}
198+
@media (forced-colors: active) and (prefers-color-scheme: light) {
199+
svg,
200+
svg > path {
201+
fill: rgb(0, 0, 0) !important;
202+
fill-rule: nonzero !important;
203+
clip-rule: nonzero !important;
204+
color: rgb(0, 0, 0) !important;
205+
}
206+
}

packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.scss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,38 @@ mgt-flyout {
318318
text-align: right !important;
319319
}
320320
}
321+
322+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
323+
svg,
324+
svg > path {
325+
fill: rgb(255, 255, 255) !important;
326+
fill-rule: nonzero !important;
327+
clip-rule: nonzero !important;
328+
color: rgb(255, 255, 255) !important;
329+
}
330+
331+
.flyout-root {
332+
border: 1px solid rgb(255, 255, 255);
333+
}
334+
335+
.people-list .list-person {
336+
border: solid 1px rgb(255, 255, 255);
337+
}
338+
}
339+
@media (forced-colors: active) and (prefers-color-scheme: light) {
340+
svg,
341+
svg > path {
342+
fill: rgb(0,0,0) !important;
343+
fill-rule: nonzero !important;
344+
clip-rule: nonzero !important;
345+
color: rgb(0,0,0) !important;
346+
}
347+
348+
.flyout-root {
349+
border: 1px solid rgb(0,0,0);
350+
}
351+
352+
.people-list .list-person {
353+
border: solid 1px rgb(0,0,0);
354+
}
355+
}

packages/mgt-components/src/components/mgt-person-card/mgt-person-card.scss

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,47 @@ $person-card-details-item-font-size: var(--person-card-details-item-font-size, 1
296296
-ms-filter: 'FlipH';
297297
}
298298
}
299+
300+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
301+
.root {
302+
border: 1px solid rgb(255, 255, 255);
303+
border-radius: inherit;
304+
305+
svg,
306+
svg > path {
307+
fill: rgb(255, 255, 255) !important;
308+
fill-rule: nonzero !important;
309+
clip-rule: nonzero !important;
310+
}
311+
}
312+
svg,
313+
svg > path,
314+
.expanded-details-container > svg,
315+
.expanded-details-container > svg > path {
316+
fill: rgb(255, 255, 255) !important;
317+
fill-rule: nonzero !important;
318+
clip-rule: nonzero !important;
319+
}
320+
}
321+
322+
@media (forced-colors: active) and (prefers-color-scheme: light) {
323+
.root {
324+
border: 1px solid rgb(0, 0, 0);
325+
border-radius: inherit;
326+
327+
svg,
328+
svg > path {
329+
fill: rgb(0, 0, 0) !important;
330+
fill-rule: nonzero !important;
331+
clip-rule: nonzero !important;
332+
}
333+
}
334+
svg,
335+
svg > path,
336+
.expanded-details-container > svg,
337+
.expanded-details-container > svg > path {
338+
fill: rgb(0, 0, 0) !important;
339+
fill-rule: nonzero !important;
340+
clip-rule: nonzero !important;
341+
}
342+
}

packages/mgt-components/src/components/mgt-person-card/sections/mgt-person-card-contact/mgt-person-card-contact.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,33 @@
139139
}
140140
}
141141
}
142+
143+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
144+
.root svg {
145+
fill: rgb(255, 255, 255) !important;
146+
fill-rule: nonzero !important;
147+
clip-rule: nonzero !important;
148+
149+
path,
150+
rect {
151+
fill: rgb(255, 255, 255) !important;
152+
fill-rule: nonzero !important;
153+
clip-rule: nonzero !important;
154+
}
155+
}
156+
}
157+
158+
@media (forced-colors: active) and (prefers-color-scheme: light) {
159+
.root svg {
160+
fill: rgb(0,0,0) !important;
161+
fill-rule: nonzero !important;
162+
clip-rule: nonzero !important;
163+
164+
path,
165+
rect {
166+
fill: rgb(0,0,0) !important;
167+
fill-rule: nonzero !important;
168+
clip-rule: nonzero !important;
169+
}
170+
}
171+
}

packages/mgt-components/src/components/mgt-person-card/sections/mgt-person-card-organization/mgt-person-card-organization.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,21 @@
186186
}
187187
}
188188
}
189+
190+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
191+
:host svg,
192+
:host svg > path {
193+
fill: rgb(255, 255, 255) !important;
194+
fill-rule: nonzero !important;
195+
clip-rule: nonzero !important;
196+
}
197+
}
198+
199+
@media (forced-colors: active) and (prefers-color-scheme: light) {
200+
:host svg,
201+
:host svg > path {
202+
fill: rgb(0, 0, 0) !important;
203+
fill-rule: nonzero !important;
204+
clip-rule: nonzero !important;
205+
}
206+
}

packages/mgt-components/src/components/mgt-person/mgt-person.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,25 @@ mgt-person .avatar-icon {
489489
}
490490
}
491491
}
492+
493+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
494+
:host svg,
495+
:host svg > path,
496+
mgt-person svg,
497+
mgt-person svg > path {
498+
fill: rgb(255, 255, 255) !important;
499+
fill-rule: nonzero !important;
500+
clip-rule: nonzero !important;
501+
}
502+
}
503+
504+
@media (forced-colors: active) and (prefers-color-scheme: dark) {
505+
:host svg,
506+
:host svg > path,
507+
mgt-person svg,
508+
mgt-person svg > path {
509+
fill: rgb(0,0,0) !important;
510+
fill-rule: nonzero !important;
511+
clip-rule: nonzero !important;
512+
}
513+
}

0 commit comments

Comments
 (0)