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

gulp, and select style #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ package-lock.json
dist/
.vscode/
*.log
yarn.lock
26 changes: 26 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import gulp from 'gulp'
import cssSelectorExtract from 'css-selector-extract'
import through2 from 'through2'

var extract = function() {
return gulp
.src('src/elements/select.shared.css')
.pipe(
through2.obj(function(file, _, cb) {
if (file.isBuffer()) {
const code = file.contents.toString()
const extractedCss = cssSelectorExtract.processSync({
// CSS source code as string.
css: code,
// Array of selectors which should get extracted.
filters: [/^(.*)select(.*)/],
})
file.contents = Buffer.from(extractedCss)
}
cb(null, file)
}),
)
.pipe(gulp.dest('dist/'))
}

gulp.task('default', extract)
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
"version": "lume versionHook",
"postversion": "lume postVersionHook",
"OTHER SCRIPTS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "",
"examples": "live-server --open=playground --no-css-inject"
"examples": "live-server --open=playground --no-css-inject",
"gulp": "gulp"
},
"dependencies": {},
"devDependencies": {
"@lume/cli": "^0.3.0",
"live-server": "^1.2.1",
"prettier": "^1.19.1"
"prettier": "^1.19.1",
"gulp": "^4.0.2",
"css-selector-extract": "^4.0.0",
"through2": "^4.0.2"
},
"repository": {
"type": "git",
Expand Down
11 changes: 9 additions & 2 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
<title>Playground</title>
<style>
@import '../src/index.css';
@import '../src/extra/utils.css';

body {
font-family: sans-serif;
color: #626e84;
}

</style>
</head>

<body>


<h1>LUME Basicss Playground</h1>

<fieldset checkboxes inline-block>
Expand Down Expand Up @@ -210,6 +209,14 @@ <h2>Lists</h2>
<li>Adds Bullets to Page</li>
</ol>

<hr />

<label for="country">Country</label>
<select id="country">
<option selected>Choose...</option>
<option>...</option>
</select>

<hr />
<h2>Forms</h2>

Expand Down
21 changes: 0 additions & 21 deletions src/clickables.css

This file was deleted.

4 changes: 0 additions & 4 deletions src/elements/body.css

This file was deleted.

2 changes: 0 additions & 2 deletions src/elements/button.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../shared/colors.css';

input[type='button' i],
input[type='reset' i],
input[type='submit' i],
Expand Down
205 changes: 205 additions & 0 deletions src/elements/form/form.shared-is-test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
select {
--line-height: 1.5;
--form-element-spacing-vertical: 0.75rem;
--form-element-spacing-horizontal: 1rem;
--form-element-border-width: 1px;
--block-round: 0.25rem;
--text: #415462;
--input-border: #c8d1d8;
--text-weight: 400;
--form-element-weight: var(--text-weight);
--mark-text: #2c3d49;
--muted-background: #edf0f3;
--icon-valid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(40, 138, 106, 0.999)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
--icon-invalid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(185, 70, 70, 0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");
--icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(115, 130, 140, 0.999)' opacity='0.66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
--spacing-typography: 1.5rem;
--form-element-outline-width: 3px;
--primary-focus: rgba(16, 149, 193, 0.125);
--input-focus: var(--primary-focus);
}

button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 1rem; /* 1 */
line-height: var(--line-height); /* 1 */
margin: 0; /* 2 */
}

select,
textarea,
form {
display: block;
width: 100%;
}

input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='file']),
select,
textarea {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: var(--form-element-spacing-vertical) var(--form-element-spacing-horizontal);
vertical-align: middle;
}

/* Remove the inheritance of text transform in Edge, Firefox, and IE */
select {
text-transform: none;
}

input,
select,
textarea {
border: var(--form-element-border-width) solid var(--input-border);
border-radius: var(--block-round);
outline: none;
background-color: var(--input-background);
color: var(--text);
font-weight: var(--form-element-weight);
}

input::placeholder,
select::placeholder,
textarea::placeholder,
input::-webkit-input-placeholder,
select::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
color: var(--muted-text);
opacity: 1;
}

input:active,
select:active,
textarea:active,
input:focus,
select:focus,
textarea:focus {
border-color: var(--input-hover-border);
background-color: var(--input-hover-background);
}

input[readonly],
select[readonly],
textarea[readonly],
input[disabled],
select[disabled],
textarea[disabled] {
border-color: var(--muted-border);
box-shadow: none;
}

input[readonly] ~ label,
select[readonly] ~ label,
textarea[readonly] ~ label,
input[disabled] ~ label,
select[disabled] ~ label,
textarea[disabled] ~ label {
color: var(--muted-text);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works for

<input .../>
<label>...<label>

We will also need

<label>...<label>
<input .../>

and

<label>...<input .../><label>
<label><input .../>...<label>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was just a test. Thanks for the heads up


input[readonly]:active,
select[readonly]:active,
textarea[readonly]:active,
input[disabled]:active,
select[disabled]:active,
textarea[disabled]:active,
input[readonly]:focus,
select[readonly]:focus,
textarea[readonly]:focus,
input[disabled]:focus,
select[disabled]:focus,
textarea[disabled]:focus {
box-shadow: none;
}

input[disabled]:not([type='reset']):not([type='submit']):not([type='button']),
select[disabled]:not([type='reset']):not([type='submit']):not([type='button']),
textarea[disabled]:not([type='reset']):not([type='submit']):not([type='button']) {
background-color: var(--muted-background);
}

input[disabled],
select[disabled],
textarea[disabled] {
opacity: 0.66;
}

input[aria-invalid],
select[aria-invalid],
textarea[aria-invalid] {
padding-right: 2rem;
background-position: center right 0.75rem;
background-repeat: no-repeat;
background-size: 1rem auto;
}

input[aria-invalid='false'],
select[aria-invalid='false'],
textarea[aria-invalid='false'] {
background-image: var(--icon-valid);
}

input[aria-invalid='true'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
background-image: var(--icon-invalid);
}

input:not([type='checkbox']):not([type='radio']),
select,
textarea {
margin-bottom: var(--spacing-typography);
}

input:not([type='range']):not([type='file']):focus,
select:focus,
textarea:focus {
box-shadow: 0 0 0 var(--form-element-outline-width) var(--input-focus);
}

select::-ms-expand {
border: 0;
background-color: transparent;
}

select:not([multiple]):not([size]) {
padding-right: calc(var(--form-element-spacing-horizontal) + 1.5rem);
background-image: var(--icon-chevron);
background-position: center right 0.75rem;
background-repeat: no-repeat;
background-size: 1rem auto;
}

/** Anything that is clickable should have a pointer cursor. */

select,
input[type='checkbox' i],
input[type='radio' i],
input[type='color' i],
input[type='submit' i],
input[type='button' i],
button,
input[type='date' i],
input[type='time' i],
input[type='datetime-local' i],
input[type='month' i],
input[type='week' i],
input::-webkit-calendar-picker-indicator,
input::-webkit-file-upload-button,
input[type='range' i],
input[type='reset' i],
input[type='file' i],
summary {
cursor: pointer;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is still better to try to use multiple files, if possible. Wdyt? Is there a reason to put it in here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idea is whatever is shared, have it in the same file. If you want to change the cursor it easier than go through different files.


input[type='checkbox' i]:focus,
input[type='radio' i]:focus {
outline: none;
outline-offset: 0;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* Checkboxes and radios share much of the same code. */
@import './input.shared.css';

input[type='checkbox' i] {
/* Checkboxes are boxes with rounded corners. */
--checkable-border-radius: 15%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import './input.shared.css';

input[type='color' i] {
width: auto;
padding: 4px 8px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* Checkboxes and radios share much of the same code. */
@import './input.shared.css';

/* The extra "[type]" is needed here to force this to be more specific than the rule imported from input.shared.css. :\ */
input[type='radio' i] {
/* Radios are circles. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
@import '../../shared/colors.css';
/* Clickables */

/* Various inputs use styling from button. */
@import '../button.css';
input[type='checkbox' i],
input[type='radio' i],
input[type='color' i],
input[type='submit' i],
input[type='button' i],
input[type='date' i],
input[type='time' i],
input[type='datetime-local' i],
input[type='month' i],
input[type='week' i],
input::-webkit-calendar-picker-indicator,
input::-webkit-file-upload-button,
input[type='range' i],
input[type='reset' i],
input[type='file' i] {
cursor: pointer;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see this is (mostly) duplicate of the stuff in form.shared-is-test.css

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have the duplicates?


/*
* These are default values and styles for checkbox and radio inputs, which
Expand Down
10 changes: 10 additions & 0 deletions src/elements/form/label.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
label {
user-select: none;
cursor: pointer;
}

/* label > textarea,
label > input,
label > select {
margin-top: var(--spacing-form-element);
} */
Loading