Skip to content

Commit

Permalink
Chore: Lint Css (#4745)
Browse files Browse the repository at this point in the history
Because:
- Standard CSS styling throughout the code base
- Catching CSS errors before they make it into production

This commit:
- Adds stylelint
- Disables selector-class-pattern rule because it does not like our bem
selectors
  • Loading branch information
KevinMulhern authored Aug 13, 2024
1 parent b666b7e commit 993c0b2
Show file tree
Hide file tree
Showing 15 changed files with 573 additions and 41 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
bin/rubocop --parallel
bin/erblint --lint-all
yarn run lint
yarn run stylelint
tests:
name: Tests
Expand Down
6 changes: 6 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["stylelint-config-standard"],
"rules": {
"selector-class-pattern": null
}
}
22 changes: 11 additions & 11 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
@import "tailwindcss/components";
@import "tailwindcss/utilities";

@import './stylesheets/buttons.css';
@import './stylesheets/layout.css';
@import './stylesheets/typography.css';
@import './stylesheets/buttons.css';
@import './stylesheets/lesson-content.css';
@import './stylesheets/lesson-notes.css';
@import './stylesheets/prism-theme.css';
@import './stylesheets/pagy.css';
@import './stylesheets/animations.css';
@import './stylesheets/static-pages.css';
@import './stylesheets/charts.css';
@import './custom_styles/buttons.css';
@import './custom_styles/layout.css';
@import './custom_styles/typography.css';
@import './custom_styles/buttons.css';
@import './custom_styles/lesson-content.css';
@import './custom_styles/lesson-notes.css';
@import './custom_styles/prism-theme.css';
@import './custom_styles/pagy.css';
@import './custom_styles/animations.css';
@import './custom_styles/static-pages.css';
@import './custom_styles/charts.css';
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
0% {
transform: scale(1);
}

50% {
transform: scale(1.2);
}

100% {
transform: scale(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@layer components {
.button {
min-width: 100px;

@apply inline-flex items-center px-6 justify-center py-3 border border-transparent
rounded-md shadow-sm text-white focus:outline-none
focus:ring-2 focus:ring-offset-1 hover:text-white focus:text-white no-underline
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@layer components {
.lesson-content__panel {
@apply bg-gray-100 p-6 rounded-lg dark:bg-gray-800 dark:highlight-white;
@apply bg-gray-100 p-6 rounded-lg dark:bg-gray-800 dark:highlight-white dark:prose-pre:bg-slate-800/60 dark:prose-pre:shadow-none dark:prose-pre:ring-1 dark:prose-pre:ring-slate-300/10;;
}

.lesson-content__panel > *:first-child {
Expand All @@ -19,12 +19,9 @@
@apply px-1.5 py-1 text-xs font-semibold text-gray-800 bg-gray-100 border border-gray-200 rounded-md dark:bg-gray-600 dark:text-gray-100 dark:border-gray-500;
}

.lesson-content__panel {
@apply dark:prose-pre:bg-slate-800/60 dark:prose-pre:shadow-none dark:prose-pre:ring-1 dark:prose-pre:ring-slate-300/10;
}

.lesson-content pre code {
@apply !bg-transparent p-0;

padding-top: 3px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
.lesson-note > *:first-child::before {
mask-image: url("/icons/pencil-square-solid.svg");
content:'';

@apply h-5 w-5 mr-2 inline-block align-text-bottom bg-gold dark:bg-gold-600;
}

Expand All @@ -30,6 +31,7 @@
.lesson-note--tip > *:first-child::before {
mask-image: url("/icons/light-bulb-solid.svg");
content:'';

@apply h-5 w-5 inline-block align-text-bottom bg-blue-600 dark:bg-blue-500;
}

Expand All @@ -43,6 +45,7 @@
.lesson-note--warning > *:first-child::before {
mask-image: url("/icons/exclamation-triangle-solid.svg");
content:'';

@apply h-5 w-5 inline-block align-text-bottom bg-orange-500 dark:bg-orange-400;
}

Expand All @@ -55,6 +58,7 @@
.lesson-note--critical > *:first-child::before {
mask-image: url('/icons/exclamation-circle-solid.svg');
content:'';

@apply h-5 w-5 inline-block align-text-bottom bg-red-600 dark:bg-red-500;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
.pagy-nav-js .page.prev.disabled,
.pagy-nav-js .page.next.disabled {
@apply block px-3 py-1 text-gray-500 dark:text-gray-400 font-semibold;

&:hover{
@apply text-gray-700 dark:text-gray-200;
}

&:active{
@apply text-gray-700 dark:text-gray-200;
}
Expand All @@ -24,9 +26,11 @@
.pagy-nav-js .page.prev.disabled,
.pagy-nav-js .page.next.disabled {
@apply text-gray-400 dark:text-gray-700 first-letter:cursor-default;

&:hover {
@apply text-gray-400 dark:text-gray-700;
}

&:active {
@apply text-gray-400 dark:text-gray-700;
}
Expand All @@ -35,9 +39,11 @@
.pagy-nav .page.active,
.pagy-nav-js .page.active {
@apply cursor-default text-gold-500 dark:text-gold-500;

&:hover {
@apply text-gold-500 dark:text-gold-500;
}

&:active {
@apply text-gold-500 dark:text-gold-500;
}
Expand All @@ -53,6 +59,7 @@
&:hover {
@apply text-gray-800 dark:text-gray-200;
}

&:active {
@apply text-gray-800 dark:text-gray-200;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
code[class*=language-],
pre[class*=language-] {
code[class*="language-"],
pre[class*="language-"] {
color: #ccc;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1rem;
Expand All @@ -9,25 +9,20 @@ pre[class*=language-] {
word-break: normal;
word-wrap: normal;
line-height: 1.7;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

pre[class*=language-] {
pre[class*="language-"] {
padding: 1rem;
overflow: auto;
}

code[class*=language-] {
code[class*="language-"] {
padding-top: 3px;
}

:not(pre)>code[class*=language-] {
:not(pre)>code[class*="language-"] {
padding: .1rem;
border-radius: .3rem;
white-space: normal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@layer base {
body {
font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
}

Expand All @@ -17,9 +17,10 @@
@apply dark:text-gray-200;
}

.anchor-link:hover:before {
.anchor-link:hover::before {
mask-image: url("/icons/link.svg");
content:' ';

@apply h-4 w-4 bg-gray-500 dark:bg-gray-300 absolute -left-[22px] top-1/2 -translate-y-1/2 font-semibold sm:block;
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"lint": "standard app/javascript --verbose",
"stylelint": "stylelint 'app/assets/stylesheets/custom_styles/*.css'",
"build": "node esbuild.config.mjs",
"build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --postcss"
},
Expand Down Expand Up @@ -40,7 +41,9 @@
"defaults"
],
"devDependencies": {
"standard": "^17.1.0"
"standard": "^17.1.0",
"stylelint": "^16.8.1",
"stylelint-config-standard": "^36.0.1"
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit 993c0b2

Please sign in to comment.