Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#153) Enforce using rems/ems in stylesheets #204

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"customSyntax": "postcss-less",
"extends": "stylelint-config-standard",
"ignoreFiles": ["**/*.js"],
"ignoreFiles": [
"**/*.js",
"enable-node-libs/**/*.css",
"js/out/**/*.css",
"js/enable-libs/**/*.css"
],
"rules": {
"alpha-value-notation": null,
"at-rule-empty-line-before": null,
Expand All @@ -16,18 +21,26 @@
"declaration-block-no-duplicate-properties": null,
"declaration-block-no-redundant-longhand-properties": null,
"declaration-block-no-shorthand-property-overrides": null,
"declaration-block-single-line-max-declarations": null,
"declaration-property-unit-allowed-list": {
"font-size": ["em", "rem", "vmin", "vmax", "vw", "vh"]
},
"font-family-name-quotes": null,
"font-family-no-missing-generic-family-keyword": null,
"function-calc-no-unspaced-operator": null,
"function-name-case": null,
"function-no-unknown": null,
"function-url-quotes": null,
"hue-degree-notation": null,
"import-notation": null,
"keyframes-name-pattern": null,
"length-zero-no-unit": null,
"media-feature-range-notation": null,
"media-query-no-invalid": null,
"no-empty-source": null,
"no-descending-specificity": null,
"no-duplicate-selectors": null,
"number-max-precision": null,
"property-no-unknown": null,
"property-no-vendor-prefix": null,
"rule-empty-line-before": null,
Expand Down
21 changes: 21 additions & 0 deletions bin/enforceRemFontSize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

i=`find css -name '*.css' -print`

# echo $i
OUTPUT=`grep -n 'font-size:[^\s\S]*[^@]px;' $i`
# grep -b 'line-height:[^\s\S]*[^0-9];' $i
RET="$?"

if [ "$RET" = "0" ]
then
echo "The following CSS files must be changed so they don't use px units."
echo "Please ensure you change the corresponding LESS files to use the @px mixin."
echo "(e.g. instead of using 'font-size: 12px;', use 'font-size: 12 / @px;')."
echo
echo "$OUTPUT"
echo
exit 1;
fi

exit 0
6 changes: 3 additions & 3 deletions css/accessible-text-svg.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ body {
#accessible-text-svg-demo__text {
fill: black;
stroke-width: 2px;
font-size: calc(54px * var(--text-zoom-factor));
font-size: calc(3.375rem * var(--text-zoom-factor));
font-family: "Georgia", "Times New Roman", serif;
panose-1: 0 0 0 0 0 0 0 0 0 0;
font-style: italic;
Expand All @@ -23,7 +23,7 @@ body {
transform: translateY(-4px);
}
#accessible-text-svg-demo__intro-text {
font-size: calc(54px * var(--text-zoom-factor));
font-size: calc(3.375rem * var(--text-zoom-factor));
z-index: 2;
color: black;
font-family: "Georgia", "Times New Roman", serif;
Expand All @@ -41,7 +41,7 @@ body {
width: 100%;
}
#accessible-text-svg-demo__roller-coaster-image {
left: 0px;
left: 0;
position: absolute;
top: 0;
z-index: 1;
Expand Down
4 changes: 2 additions & 2 deletions css/chart.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ body {
width: initial;
}
.chart-example svg {
font-size: 16px;
font-size: 1rem;
}
.chart-example .tick text {
font-size: calc(10px * var(--text-zoom-factor));
font-size: calc(0.625rem * var(--text-zoom-factor));
}
#bar-chart {
height: 400px;
Expand Down
116 changes: 0 additions & 116 deletions css/checkbox copy.css

This file was deleted.

6 changes: 3 additions & 3 deletions css/combobox.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
position: relative;
width: 30em;
max-width: 100%;
font-size: 100%;
font-size: 1rem;
font-family: sans-serif;
}
@media only screen and (min-width: 960px) {
Expand Down Expand Up @@ -42,7 +42,7 @@
}
.enable-combobox input[role="combobox"] {
position: relative;
font-size: 12px;
font-size: 0.75rem;
height: 1.5em;
width: 100%;
/* of pc */
Expand Down Expand Up @@ -80,7 +80,7 @@
margin: 0;
padding: 0.3em 0.5em;
list-style: none;
font-size: 12px;
font-size: 0.75rem;
cursor: pointer;
}
.enable-combobox [role="option"]:hover {
Expand Down
6 changes: 3 additions & 3 deletions css/combobox__improved.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
position: relative;
width: 30em;
max-width: 100%;
font-size: 100%;
font-size: 1rem;
font-family: sans-serif;
}
@media only screen and (min-width: 960px) {
Expand Down Expand Up @@ -41,7 +41,7 @@
}
.enable-combobox input[role="combobox"] {
position: relative;
font-size: 12px;
font-size: 0.75rem;
height: 1.5em;
width: 100%;
/* of pc */
Expand Down Expand Up @@ -80,7 +80,7 @@
margin: 0;
padding: 0.3em 0.5em;
list-style: none;
font-size: 12px;
font-size: 0.75rem;
cursor: pointer;
}
.enable-combobox [role="option"]:hover {
Expand Down
4 changes: 2 additions & 2 deletions css/enable-listbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fieldset .legend,
.enable-listbox__right-area {
box-sizing: border-box;
display: inline-block;
font-size: 14px;
font-size: 0.875rem;
vertical-align: top;
width: 50%;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ fieldset .legend,
}
.enable-listbox button {
border-radius: 0;
font-size: 16px;
font-size: 1rem;
text-align: left;
padding: 5px 10px;
width: 9.375rem;
Expand Down
2 changes: 1 addition & 1 deletion css/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ table.data img {
/* Menu button */
button {
cursor: pointer;
font-size: 110%;
font-size: 1.1rem;
}
.menu-wrapper {
position: relative;
Expand Down
26 changes: 13 additions & 13 deletions css/heading.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ div.heading-example {
text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
}
div.heading-example p {
font-size: 16px;
font-size: 1rem;
line-height: 1.4;
text-align: justify;
}
Expand Down Expand Up @@ -43,7 +43,7 @@ div.heading-example [role="heading"][aria-level="1"] {
color: #343434;
font-weight: normal;
font-family: "Ultra", sans-serif;
font-size: 36px;
font-size: 2.25rem;
line-height: 42px;
text-transform: uppercase;
text-shadow: 0 2px white, 0 3px #777;
Expand All @@ -59,13 +59,13 @@ div.heading-example [role="heading"][aria-level="5"] {
}
div.heading-example h2,
div.heading-example [role="heading"][aria-level="2"] {
font-size: 33px;
font-size: 2.0625rem;
line-height: 36.36363636px;
}
div.heading-example h5,
div.heading-example [role="heading"][aria-level="5"] {
font-size: 22px;
line-height: 54.54545455px;
font-size: 1.375rem;
line-height: 872.72727273rem;
}
div.heading-example h3,
div.heading-example h6,
Expand All @@ -81,13 +81,13 @@ div.heading-example [role="heading"][aria-level="6"] {
}
div.heading-example h3,
div.heading-example [role="heading"][aria-level="3"] {
font-size: 30px;
line-height: 29.33333333px;
font-size: 1.875rem;
line-height: 469.33333333rem;
}
div.heading-example h6,
div.heading-example [role="heading"][aria-level="6"] {
font-size: 18px;
line-height: 48.88888889px;
font-size: 1.125rem;
line-height: 782.22222222rem;
}
div.heading-example h4,
div.heading-example [role="heading"][aria-level="7"] {
Expand All @@ -98,10 +98,10 @@ div.heading-example [role="heading"][aria-level="7"] {
}
div.heading-example h4,
div.heading-example [role="heading"][aria-level="4"] {
font-size: 25px;
line-height: 14.4px;
font-size: 1.5625rem;
line-height: 230.4rem;
}
div.heading-example [role="heading"][aria-level="7"] {
font-size: 18px;
line-height: 20px;
font-size: 1.125rem;
line-height: 320rem;
}
19 changes: 0 additions & 19 deletions css/input-mask-example copy.css

This file was deleted.

2 changes: 1 addition & 1 deletion css/menubar.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ul[role="menubar"] {
margin: 10px;
padding: 10px;
font-size: 110%;
font-size: 1.1rem;
list-style: none;
background-color: #eeeeee;
}
Expand Down
Loading