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

Add first debug functions & mixins #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions index.local.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
// Output
@import 'src/index';
@import 'node_modules/@henris/default/index.scss';
@import 'node_modules/@henris/utils/index.scss';
@import 'node_modules/@henris/custom/index.scss';

$output: set-output(css, true);
$output: set-output(debug-full, false);

@import 'node_modules/@henris/output/index.scss';
@import 'src/index';
2 changes: 1 addition & 1 deletion index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Output
@import 'src/index';
@import 'src/index';
79 changes: 76 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
"stylelint-order": "^3.1.0"
},
"dependencies": {
"@henris/output": "^0.0.6",
"@henris/custom": "0.0.2",
"@henris/default": "0.0.2",
"@henris/grid": "0.0.11",
"@henris/output": "0.0.6",
"@henris/utils": "^0.0.14"
}
}
127 changes: 127 additions & 0 deletions src/functions/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
@if output(debug-full) or output(debug-layout){
body * { background-color: rgba(255,0,0,.2); }
body * * { background-color: rgba(0,255,0,.2); }
body * * * { background-color: rgba(0,0,255,.2); }
body * * * * { background-color: rgba(255,0,255,.2); }
body * * * * * { background-color: rgba(0,255,255,.2); }
body * * * * * * { background-color: rgba(255,255,0,.2); }
body * * * * * * * { background-color: rgba(255,0,0,.2); }
body * * * * * * * * { background-color: rgba(0,255,0,.2); }
body * * * * * * * * * { background-color: rgba(0,0,255,.2); }

b > div,
i > div,
q > div,
em > div,
abbr > div,
cite > div,
span > div,
small > div,
label > div,
strong > div {
@include debug-warning("You shouldn\'t use a div in an inline element");
}
}

@if output(debug-full) or output(debug-image){
img:not([alt]),
img[alt=''] {
@include debug-warning('Images always need an alt text.');
}
}

@if output(debug-full) or output(debug-link){
a:not([href]),
a[href=''] {
@include debug-warning('Link always required a href.');
}
//
a[target$='blank']:not([rel]),
a[target$='blank']:not([rel*='noopener']):not([rel*='noreferrer']){
@include debug-warning('a[target=_blank] always needs a rel=noopener');
}
//
a[href^='javascript']:not([role='button']) {
@include debug-warning(
'Don\'t add javascript to a link attribute, use a button instead'
);
}
}

@if output(debug-full) or output(debug-details){
details > summary:not(:first-child) {
@include debug-warning(
'Summary should always be the first child in a details'
);
}
//
dt + :not(dd),
:not(dt):not(dd) + dd {
@include debug-warning('DL can only have DT or DD as children');
}
:not(dl) > dt,
:not(dl) > dd,
dl > :not(dt):not(dd):not(div) {
@include debug-warning('DT and DD can only be used in a DL');
}
}

@if output(debug-full) or output(debug-list) {
:not(ul):not(ol) > li {
@include debug-warning('LI can only be used in a OL or UL');
}
}

@if output(debug-full) or output(debug-form) {
label:not([for]):not(>input),
label[for=' ']:not(>input),
label[for='']:not(>input) {
@include debug-warning('Label always requires an for attribute');
}
input:not([type]),
input[type=' '],
input[type=''] {
@include debug-warning('Input always requires an input type');
}
input:not([name]),
input[name=' '],
input[name=''] {
@include debug-warning('Input always requires an name attribute');
}

}

@if output(debug-full) or output(debug-legend) {
fieldset > legend:not(:first-child) {
@include debug-warning(
'Legend should always be the first child in a fieldset'
);
}
}

@if output(debug-full) or output(debug-abbr) {
abbr:not([title]),
abbr[title=' '],
abbr[title=''] {
@include debug-warning(
'Summary should always be the first child in a details'
);
}
}

@if output(debug-full) or output(debug-figcaption) {
:not(figure) > figcaption {
@include debug-warning('Figcaption can only be used in a DL');
}
}

@if output(debug-bad-compute) {
[id*="NaN"],
[id*="null"],
[class*="NaN"],
[class*="null"],
[id*="undefined"],
[class*="undefined"] {
@include debug-warning("There is probably something wrong with this element, check the ID or class");
}
}
3 changes: 2 additions & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// Debugging
@import 'mixins/index';
@import 'functions/index';
39 changes: 39 additions & 0 deletions src/mixins/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@mixin debug-warning($text) {
position: relative;
outline: 1px dashed red;
&::before {
content: "#{$text}";
position: absolute;
top: 0;
left: 0;
background-color: red;
color: white;
padding: 0.25rem 0.5rem;
}
}


@mixin debug-layout{
body * { background-color: rgba(255,0,0,.2); }
body * * { background-color: rgba(0,255,0,.2); }
body * * * { background-color: rgba(0,0,255,.2); }
body * * * * { background-color: rgba(255,0,255,.2); }
body * * * * * { background-color: rgba(0,255,255,.2); }
body * * * * * * { background-color: rgba(255,255,0,.2); }
body * * * * * * * { background-color: rgba(255,0,0,.2); }
body * * * * * * * * { background-color: rgba(0,255,0,.2); }
body * * * * * * * * * { background-color: rgba(0,0,255,.2); }

b > div,
i > div,
q > div,
em > div,
abbr > div,
cite > div,
span > div,
small > div,
label > div,
strong > div {
@include debug-warning("You shouldn\'t use a div in an inline element");
}
}
5 changes: 4 additions & 1 deletion test/index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
@import "../node_modules/ssst/index.scss";
// @debug 'Tests yet to be made';
@import '../index.local.scss';


@include debug-layout;