Skip to content

Commit

Permalink
perf(ui): improve web accessibility (#447)
Browse files Browse the repository at this point in the history
- Make color and contrast meets WCAG 2 AA and above
- Fixes `aria-label` on button "copy link" in posts
  • Loading branch information
cotes2020 committed Aug 2, 2023
1 parent 0fd4c0b commit 37c9764
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 83 deletions.
8 changes: 5 additions & 3 deletions _includes/post-sharing.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
</a>
{% endfor %}

<i
<button
id="copy-link"
class="fa-fw fas fa-link small"
aria-label="Copy link"
class="btn small"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="{{ site.data.locales[include.lang].post.button.share_link.title }}"
data-title-succeed="{{ site.data.locales[include.lang].post.button.share_link.succeed }}"
>
</i>
<i class="fa-fw fas fa-link pe-none"></i>
</button>
</span>
</div>
10 changes: 9 additions & 1 deletion _javascript/modules/components/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ export function initClipboard() {

/* --- Post link sharing --- */

$('#copy-link').on('click', (e) => {
const btnCopyLink = $('#copy-link');

btnCopyLink.on('click', (e) => {
let target = $(e.target);

if (isLocked(target)) {
Expand All @@ -120,4 +122,10 @@ export function initClipboard() {
}, TIMEOUT);
});
});

btnCopyLink.on('mouseleave', function (e) {
const target = $(e.target);
target.tooltip('hide');
console.log('mouse leave...');
});
}
18 changes: 10 additions & 8 deletions _sass/addon/commons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ footer {
font-size: 0.8rem;
background-color: var(--main-bg);

@extend %text-color;

div.d-flex {
height: $footer-height;
line-height: 1.2rem;
Expand All @@ -185,7 +187,7 @@ footer {
}

a {
@extend %text-color;
@extend %text-highlight;

&:hover {
@extend %link-hover;
Expand Down Expand Up @@ -243,7 +245,6 @@ i {
.post-tag {
line-height: 1.05rem;
font-size: 0.85rem;
border: 1px solid var(--btn-border-color);
border-radius: 0.8rem;
padding: 0.3rem 0.5rem;
margin: 0 0.35rem 0.5rem 0;
Expand Down Expand Up @@ -494,9 +495,10 @@ i {
display: inline-block;
min-width: 2rem;
text-align: center;
border-radius: 0.3rem;
border-radius: 0.5rem;
border: 1px solid var(--btn-border-color);
padding: 0 0.4rem;
color: inherit;
color: var(--text-muted-color);
line-height: 1.3rem;

&:not(:last-child) {
Expand Down Expand Up @@ -745,19 +747,20 @@ $btn-mb: 0.5rem;
font-size: 1.75rem;
line-height: 1.2;
letter-spacing: 0.25px;
color: rgba(134, 133, 133, 0.99);
margin-top: 1.25rem;
margin-bottom: 0.5rem;

a {
@extend %clickable-transition;
@extend %sidebar-link-hover;

color: var(--site-title-color);
}
}

.site-subtitle {
font-size: 95%;
color: var(--sidebar-muted-color);
color: var(--site-subtitle-color);
margin-top: 0.25rem;
word-spacing: 1px;
-webkit-user-select: none;
Expand Down Expand Up @@ -915,7 +918,7 @@ $btn-mb: 0.5rem;

#breadcrumb {
font-size: 1rem;
color: gray;
color: var(--text-muted-color);
padding-left: 0.5rem;

a:hover {
Expand Down Expand Up @@ -1102,7 +1105,6 @@ $btn-mb: 0.5rem;
/* --- main wrapper --- */

#main-wrapper {
background-color: var(--main-bg);
position: relative;
min-height: calc(100vh - $footer-height-mobile);

Expand Down
7 changes: 6 additions & 1 deletion _sass/addon/module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
}

%sidebar-links {
color: rgba(117, 117, 117, 0.9);
color: var(--sidebar-muted-color);
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
Expand All @@ -122,6 +122,11 @@
-webkit-box-orient: vertical;
}

%text-highlight {
color: inherit;
font-weight: 600;
}

/* ---------- scss mixin --------- */

@mixin mt-mb($value) {
Expand Down
1 change: 1 addition & 0 deletions _sass/addon/syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ html {
font-size: $code-font-size;
line-height: 1.4rem;
word-wrap: normal; /* Fixed Safari overflow-x */
color: var(--code-snippets-color);
}

table {
Expand Down
36 changes: 16 additions & 20 deletions _sass/colors/dark-syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,40 @@
@mixin dark-syntax {
--language-border-color: rgba(84, 83, 83, 0.27);
--highlight-bg-color: #252525;
--highlighter-rouge-color: #de6b18;
--highlight-lineno-color: #6c6c6d;
--highlighter-rouge-color: #ff6e4e;
--highlight-lineno-color: #666666;
--inline-code-bg: #272822;
--code-header-text-color: #6a6a6a;
--code-header-muted-color: rgb(60, 60, 60);
--code-header-icon-color: rgb(86, 86, 86);
--clipboard-checked-color: #2bcc2b;
--filepath-text-color: #bdbdbd;

/* override Bootstrap */
pre {
color: #bfbfbf;
}
--filepath-text-color: #cacaca;
--code-snippets-color: #c2c2c2;

.highlight .gp {
color: #818c96;
color: #87939d;
}

/* syntax highlight colors from https://raw.githubusercontent.com/jwarby/pygments-css/master/monokai.css */

.highlight pre { background-color: var(--highlight-bg-color); }
.highlight .hll { background-color: var(--highlight-bg-color); }
.highlight .c { color: #75715e; } /* Comment */
.highlight .c { color: #938d75; } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010; } /* Error */
.highlight .k { color: #66d9ef; } /* Keyword */
.highlight .l { color: #ae81ff; } /* Literal */
.highlight .n { color: #f8f8f2; } /* Name */
.highlight .o { color: #f92672; } /* Operator */
.highlight .o { color: #ff329c; } /* Operator */
.highlight .p { color: #f8f8f2; } /* Punctuation */
.highlight .cm { color: #75715e; } /* Comment.Multiline */
.highlight .cp { color: #75715e; } /* Comment.Preproc */
.highlight .c1 { color: #75715e; } /* Comment.Single */
.highlight .cs { color: #75715e; } /* Comment.Special */
.highlight .cm { color: #938d75; } /* Comment.Multiline */
.highlight .cp { color: #938d75; } /* Comment.Preproc */
.highlight .c1 { color: #938d75; } /* Comment.Single */
.highlight .cs { color: #938d75; } /* Comment.Special */
.highlight .ge { color: inherit; font-style: italic; } /* Generic.Emph */
.highlight .gs { font-weight: bold; } /* Generic.Strong */
.highlight .kc { color: #66d9ef; } /* Keyword.Constant */
.highlight .kd { color: #66d9ef; } /* Keyword.Declaration */
.highlight .kn { color: #f92672; } /* Keyword.Namespace */
.highlight .kn { color: #ff329c; } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef; } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef; } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef; } /* Keyword.Type */
Expand All @@ -61,9 +57,9 @@
.highlight .nn { color: #f8f8f2; } /* Name.Namespace */
.highlight .nx { color: #a6e22e; } /* Name.Other */
.highlight .py { color: #f8f8f2; } /* Name.Property */
.highlight .nt { color: #f92672; } /* Name.Tag */
.highlight .nt { color: #ff329c; } /* Name.Tag */
.highlight .nv { color: #f8f8f2; } /* Name.Variable */
.highlight .ow { color: #f92672; } /* Operator.Word */
.highlight .ow { color: #ff329c; } /* Operator.Word */
.highlight .w { color: #f8f8f2; } /* Text.Whitespace */
.highlight .mf { color: #ae81ff; } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff; } /* Literal.Number.Hex */
Expand All @@ -85,7 +81,7 @@
.highlight .vg { color: #f8f8f2; } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2; } /* Name.Variable.Instance */
.highlight .il { color: #ae81ff; } /* Literal.Number.Integer.Long */
.highlight .gu { color: #75715e; } /* Generic.Subheading & Diff Unified/Comment? */
.highlight .gd { color: #f92672; background-color: #561c08; } /* Generic.Deleted & Diff Deleted */
.highlight .gu { color: #938d75; } /* Generic.Subheading & Diff Unified/Comment? */
.highlight .gd { color: #ff329c; background-color: #561c08; } /* Generic.Deleted & Diff Deleted */
.highlight .gi { color: #a6e22e; background-color: #0b5858; } /* Generic.Inserted & Diff Inserted */
}
10 changes: 5 additions & 5 deletions _sass/colors/dark-typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

/* Common color */
--text-color: rgb(175, 176, 177);
--text-muted-color: rgb(107, 116, 124);
--text-muted-color: rgb(125, 136, 146);
--heading-color: #cccccc;
--label-color: #a4a4c2;
--blockquote-border-color: rgb(66, 66, 66);
--blockquote-text-color: rgb(117, 117, 117);
--blockquote-text-color: #868686;
--link-color: rgb(138, 180, 248);
--link-underline-color: rgb(82, 108, 150);
--button-bg: rgb(39, 40, 43);
Expand All @@ -22,7 +23,6 @@
--btn-backtotop-border-color: var(--btn-border-color);
--btn-box-shadow: var(--main-bg);
--card-header-bg: rgb(48, 48, 48);
--label-color: rgb(108, 117, 125);
--checkbox-color: rgb(118, 120, 121);
--checkbox-checked-color: var(--link-color);
--img-bg: radial-gradient(circle, rgb(22, 22, 24) 0%, rgb(32, 32, 32) 100%);
Expand All @@ -34,6 +34,8 @@
);

/* Sidebar */
--site-title-color: #717070;
--site-subtitle-color: #6d6c6b;
--sidebar-bg: radial-gradient(circle, #242424 0%, #1d1f27 100%);
--sidebar-muted-color: #6d6c6b;
--sidebar-active-color: rgb(255, 255, 255, 0.95);
Expand All @@ -58,15 +60,13 @@

/* Posts */
--toc-highlight: rgb(116, 178, 243);
--tag-bg: rgb(41, 40, 40);
--tag-hover: rgb(43, 56, 62);
--tb-odd-bg: rgba(42, 47, 53, 0.52); /* odd rows of the posts' table */
--tb-even-bg: rgb(31, 31, 34); /* even rows of the posts' table */
--tb-border-color: var(--tb-odd-bg);
--footnote-target-bg: rgb(63, 81, 181);
--btn-share-color: #6c757d;
--btn-share-hover-color: #bfc1ca;
--relate-post-date: var(--text-muted-color);
--card-bg: #1e1e1e;
--card-hovor-bg: #464d51;
--card-shadow: rgb(21, 21, 21, 0.72) 0 6px 18px 0,
Expand Down
45 changes: 23 additions & 22 deletions _sass/colors/light-syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
*/

@mixin light-syntax {
/* see: <https://raw.githubusercontent.com/jwarby/pygments-css/master/github.css> */
/* based on: <https://raw.githubusercontent.com/jwarby/pygments-css/master/github.css> */
.highlight .hll { background-color: #ffffcc; }
.highlight .c { color: #999988; font-style: italic; } /* Comment */
.highlight .c { color: #717165; font-style: italic; } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2; } /* Error */
.highlight .k { color: #000000; font-weight: bold; } /* Keyword */
.highlight .o { color: #000000; font-weight: bold; } /* Operator */
.highlight .cm { color: #999988; font-style: italic; } /* Comment.Multiline */
.highlight .cp { color: #999999; font-weight: bold; font-style: italic; } /* Comment.Preproc */
.highlight .c1 { color: #999988; font-style: italic; } /* Comment.Single */
.highlight .cs { color: #999999; font-weight: bold; font-style: italic; } /* Comment.Special */
.highlight .cm { color: #717165; font-style: italic; } /* Comment.Multiline */
.highlight .cp { color: #707070; font-style: italic; } /* Comment.Preproc */
.highlight .c1 { color: #717165; font-style: italic; } /* Comment.Single */
.highlight .cs { color: #707070; font-weight: bold; font-style: italic; } /* Comment.Special */
.highlight .gd { color: #d01040; background-color: #ffdddd; } /* Generic.Deleted */
.highlight .ge { color: #000000; font-style: italic; } /* Generic.Emph */
.highlight .gr { color: #aa0000; } /* Generic.Error */
.highlight .gh { color: #999999; } /* Generic.Heading */
.highlight .gi { color: #008080; background-color: #ddffdd; } /* Generic.Inserted */
.highlight .go { color: #888888; } /* Generic.Output */
.highlight .gh { color: #707070; } /* Generic.Heading */
.highlight .gi { color: #005e5e; background-color: #ddffdd; } /* Generic.Inserted */
.highlight .go { color: #707070; } /* Generic.Output */
.highlight .gp { color: #555555; } /* Generic.Prompt */
.highlight .gs { font-weight: bold; } /* Generic.Strong */
.highlight .gu { color: #aaaaaa; } /* Generic.Subheading */
Expand All @@ -31,18 +31,18 @@
.highlight .kt { color: #445588; font-weight: bold; } /* Keyword.Type */
.highlight .m { color: #009999; } /* Literal.Number */
.highlight .s { color: #d01040; } /* Literal.String */
.highlight .na { color: #008080; } /* Name.Attribute */
.highlight .nb { color: #0086b3; } /* Name.Builtin */
.highlight .na { color: #005e5e; } /* Name.Attribute */
.highlight .nb { color: #0078a1; } /* Name.Builtin */
.highlight .nc { color: #445588; font-weight: bold; } /* Name.Class */
.highlight .no { color: #008080; } /* Name.Constant */
.highlight .no { color: #005e5e; } /* Name.Constant */
.highlight .nd { color: #3c5d5d; font-weight: bold; } /* Name.Decorator */
.highlight .ni { color: #800080; } /* Name.Entity */
.highlight .ne { color: #990000; font-weight: bold; } /* Name.Exception */
.highlight .nf { color: #990000; font-weight: bold; } /* Name.Function */
.highlight .nl { color: #990000; font-weight: bold; } /* Name.Label */
.highlight .nn { color: #555555; } /* Name.Namespace */
.highlight .nt { color: #000080; } /* Name.Tag */
.highlight .nv { color: #008080; } /* Name.Variable */
.highlight .nv { color: #005e5e; } /* Name.Variable */
.highlight .ow { color: #000000; font-weight: bold; } /* Operator.Word */
.highlight .w { color: #bbbbbb; } /* Text.Whitespace */
.highlight .mf { color: #009999; } /* Literal.Number.Float */
Expand All @@ -60,22 +60,23 @@
.highlight .sr { color: #009926; } /* Literal.String.Regex */
.highlight .s1 { color: #d01040; } /* Literal.String.Single */
.highlight .ss { color: #990073; } /* Literal.String.Symbol */
.highlight .bp { color: #999999; } /* Name.Builtin.Pseudo */
.highlight .vc { color: #008080; } /* Name.Variable.Class */
.highlight .vg { color: #008080; } /* Name.Variable.Global */
.highlight .vi { color: #008080; } /* Name.Variable.Instance */
.highlight .bp { color: #707070; } /* Name.Builtin.Pseudo */
.highlight .vc { color: #005e5e; } /* Name.Variable.Class */
.highlight .vg { color: #005e5e; } /* Name.Variable.Global */
.highlight .vi { color: #005e5e; } /* Name.Variable.Instance */
.highlight .il { color: #009999; } /* Literal.Number.Integer.Long */

/* --- custom light colors --- */
--language-border-color: rgba(172, 169, 169, 0.2);
--highlight-bg-color: #f7f7f7;
--highlight-bg-color: #fcfcfc;
--highlighter-rouge-color: #3f596f;
--highlight-lineno-color: #c2c6cc;
--highlight-lineno-color: #959595;
--inline-code-bg: #f6f6f7;
--code-header-text-color: #a3a3b1;
--code-header-muted-color: #ebebeb;
--code-header-icon-color: #d1d1d1;
--code-header-text-color: #a3a3a3;
--code-header-muted-color: #e2e1e1;
--code-header-icon-color: #c9c8c8;
--clipboard-checked-color: #43c743;
--code-snippets-color: #b01662;

[class^='prompt-'] {
--inline-code-bg: #fbfafa;
Expand Down
Loading

0 comments on commit 37c9764

Please sign in to comment.