@anyblades/blades 0.28.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,129 @@
1
+ /* <!--section:code-->
2
+ ```css */
3
+ label:has(input:not([type="checkbox"], [type="radio"], [type="range"]), textarea, select),
4
+ .has-float-label {
5
+ /* Default/fallback state */
6
+ > span,
7
+ label {
8
+ padding-inline-start: calc(1rem + 1px); /* match Pico's padding + border */
9
+ padding-block-start: 0.25rem;
10
+ opacity: 75%;
11
+ transition: all 0.25s;
12
+ }
13
+ input,
14
+ textarea,
15
+ select {
16
+ margin-block-start: 0; /* reset Pico */
17
+ padding-inline-start: 1rem; /* match Pico */
18
+ padding-block: 1.125rem 0.375rem; /* match Pico's total: 2 x 0.75rem = 1.5rem */
19
+
20
+ &::placeholder {
21
+ opacity: 100%;
22
+ transition: all 0.25s;
23
+ }
24
+ }
25
+
26
+ /* Enlarged state */
27
+ &:has(*:placeholder-shown:not(:focus)) {
28
+ > span,
29
+ label {
30
+ padding-block: 0.75rem; /* match Pico */
31
+ }
32
+ }
33
+ }
34
+ body {
35
+ /* Make the `body` a flex container with column layout, and `main` to automatically fill available space. This is useful for creating sticky footers and full-height layouts. */
36
+ display: flex;
37
+ flex-direction: column;
38
+ > main {
39
+ flex-grow: 1;
40
+ }
41
+ }
42
+ a {
43
+ &:not([href^="#"]) {
44
+ text-decoration-thickness: 1px;
45
+ &:hover {
46
+ text-decoration-thickness: 2px;
47
+ }
48
+ }
49
+ }
50
+ h1 {
51
+ font-size: 2.5em; /* for pico.css & tw-typography */
52
+ margin-bottom: 1rem; /* for tw-typography */
53
+ }
54
+ /* Potential fix https://github.com/picocss/pico/blob/main/css/pico.css for the very first headings
55
+ :where(article, address, blockquote, dl, figure, form, ol, p, pre, table, ul) ~ :is(h1, h2, h3, h4, h5, h6) {
56
+ margin-top: var(--pico-typography-spacing-top);
57
+ }
58
+ h1,
59
+ h2,
60
+ h3,
61
+ h4,
62
+ h5,
63
+ h6 {
64
+ & ~ & {
65
+ margin-bottom: 2rem;
66
+ }
67
+ }
68
+ NOTE: be careful with wrapped headings, i.e. inside nav: https://blades.ninja/build-awesome-11ty/#usage
69
+ */
70
+ hr {
71
+ margin-block: 2em; /* for pico.css & tw-typography */
72
+ }
73
+ ul {
74
+ ul {
75
+ font-size: 87.5%;
76
+ }
77
+ }
78
+ pre {
79
+ small {
80
+ opacity: 75%;
81
+ font-weight: lighter;
82
+ }
83
+ }
84
+ table {
85
+ th {
86
+ vertical-align: bottom;
87
+ font-weight: bold;
88
+ }
89
+ td {
90
+ vertical-align: top;
91
+ }
92
+ pre {
93
+ margin-bottom: 0.25rem;
94
+ }
95
+ }
96
+ [data-jump-to="top"] {
97
+ > i {
98
+ display: inline-block;
99
+ padding: 0.25rem 0.375rem;
100
+ margin: 0.5rem;
101
+ font-size: 0.75rem;
102
+ color: black;
103
+ border-color: black;
104
+ }
105
+ }
106
+ [data-is-toc] {
107
+ font-size: 87.5%;
108
+
109
+ a {
110
+ text-decoration: none;
111
+ }
112
+ > ul > * > a {
113
+ font-weight: 500;
114
+ }
115
+ }
116
+ .breakout,
117
+ .breakout-all {
118
+ > img,
119
+ > figure {
120
+ margin-bottom: 1rem;
121
+ }
122
+ }
123
+ .faded {
124
+ a {
125
+ text-decoration-style: dotted;
126
+ }
127
+ }
128
+ /*```
129
+ <!--section--> */
@@ -0,0 +1,98 @@
1
+ /* <!--section:code-->```css */
2
+ .breakout,
3
+ .breakout-all {
4
+ /* Prepare the container for breakout elements */
5
+ padding-inline: 10%;
6
+ max-width: calc(10% + 65ch + 10%);
7
+
8
+ /* Breakout direct children only */
9
+ & > * {
10
+ &:is(
11
+ table,
12
+ pre,
13
+ figure, video, iframe, canvas,
14
+ img, picture,
15
+ /* Custom utility classes for other tags that need to be broken out */
16
+ .breakout-item,
17
+ .breakout-item-max
18
+ ) {
19
+ width: fit-content;
20
+ min-width: 100%;
21
+ max-width: 125%;
22
+ margin-left: 50%;
23
+ transform: translateX(-50%);
24
+ }
25
+
26
+ /* Respect img/picture min-width */
27
+ &:is(img, picture) {
28
+ min-width: auto;
29
+ }
30
+
31
+ /* Max out the width of the element */
32
+ &.breakout-item-max {
33
+ width: 125% !important; /* !important is for cases like figure.breakout-item-max @TODO */
34
+ }
35
+ }
36
+ }
37
+ .breakout-all > * {
38
+ &:is(h2, h3, h4, h5, h6, hr):not([class]) {
39
+ position: relative;
40
+
41
+ &::before {
42
+ content: "";
43
+ display: block;
44
+ position: absolute;
45
+ background: gray;
46
+ opacity: 12.5%;
47
+ }
48
+ }
49
+
50
+ &:is(h2, h3, h4, h5, h6):not([class]) {
51
+ &::before {
52
+ width: 10em;
53
+ right: 100%;
54
+ margin-right: 0.8ch;
55
+ height: 0.25em;
56
+ top: 50%;
57
+ transform: translateY(-50%);
58
+ background: linear-gradient(to left, gray, transparent);
59
+ }
60
+
61
+ /* @TODO: add to tricks-wiki why `*` works here, but `&` fails */
62
+ &:where(hr + *) {
63
+ &::before {
64
+ display: none !important;
65
+ }
66
+ }
67
+ }
68
+ &:is(hr) {
69
+ height: 0.5rem;
70
+ border: none;
71
+ overflow: visible;
72
+
73
+ &::before {
74
+ width: 100vw;
75
+ left: 50%;
76
+ height: 100%;
77
+ transform: translateX(-50%);
78
+ }
79
+ }
80
+ }
81
+ /*```
82
+ <!--section:docs,summary-->
83
+
84
+ Framework-agnostic utilities for breaking out images and figures beyond their container width.
85
+
86
+ Use the `.breakout` class to allow elements to extend beyond their parent container.
87
+
88
+ <!--section:docs-->
89
+
90
+ ```html
91
+ <div class="breakout">
92
+ <img src="image.jpg" alt="Description" />
93
+ </div>
94
+ ```
95
+
96
+ The breakout container has `10%` inline padding and a max-width of `calc(10% + 65ch + 10%)`. The breakout utilities support images, pictures, figures, canvas, audio, video, tables, pre, iframe, and other media elements. Tables inside `.breakout` are specifically enhanced for horizontal scrolling and full-bleed mobile display. This is automatically included when you import the stylesheet.
97
+
98
+ <!--section--> */
@@ -0,0 +1,44 @@
1
+ /* Moved here from https://github.com/anyblades/float-label-css for easier maintenance
2
+ <!--section:docs-->
3
+
4
+ First, we target either:
5
+ 1. `<label>` which `:has` inner form inputs (classless approach)
6
+ 2. or explicit `.has-float-label` class (alternative approach)
7
+ ```css */
8
+ label:has(input:not([type="checkbox"], [type="radio"], [type="range"]), textarea, select),
9
+ .has-float-label {
10
+ display: block;
11
+ position: relative;
12
+ /*
13
+ ```
14
+ Then, we define the default/fallback state (when the float label should be minimized):
15
+ ```css */
16
+ > span,
17
+ label {
18
+ position: absolute;
19
+ left: 0;
20
+ top: 0;
21
+ cursor: text;
22
+ font-size: 75%;
23
+ }
24
+ /*
25
+ ```
26
+ Finally, we detect if placeholder is shown, but not in focus. That means we can safely hide it, and enlarge the float label instead:
27
+ ```css */
28
+ *:placeholder-shown:not(:focus)::placeholder {
29
+ opacity: 0;
30
+ }
31
+ &:has(*:placeholder-shown:not(:focus)) {
32
+ > span,
33
+ label {
34
+ font-size: inherit;
35
+ opacity: 50%;
36
+ }
37
+ }
38
+ }
39
+ /*
40
+ ```
41
+ The `:has(*:placeholder-shown:not(:focus))` trick allows this input state information to *propagate* to the parent level. This enables modern CSS to target inner float label (`<span>` or `<label>`) regardless of its position relative to the input field.
42
+
43
+ Historically, this was not possible: the float label had to be placed after the input field to be targeted using the `input:focus + label` selector.
44
+ <!--section--> */
@@ -0,0 +1,76 @@
1
+ /* Float Label CSS v2.0.0-alpha */
2
+ /* Moved here from https://github.com/anyblades/float-label-css for easier maintenance
3
+ <!--section:docs-->
4
+
5
+ First, we target either:
6
+ 1. `<label>` which `:has` inner form inputs (classless approach)
7
+ 2. or explicit `.has-float-label` class (alternative approach)
8
+ ```css */
9
+ label:has(input:not([type="checkbox"], [type="radio"], [type="range"]), textarea, select),
10
+ .has-float-label {
11
+ display: block;
12
+ position: relative;
13
+ /*
14
+ ```
15
+ Then, we define the default/fallback state (when the float label should be minimized):
16
+ ```css */
17
+ > span,
18
+ label {
19
+ position: absolute;
20
+ left: 0;
21
+ top: 0;
22
+ cursor: text;
23
+ font-size: 75%;
24
+ }
25
+ /*
26
+ ```
27
+ Finally, we detect if placeholder is shown, but not in focus. That means we can safely hide it, and enlarge the float label instead:
28
+ ```css */
29
+ *:placeholder-shown:not(:focus)::placeholder {
30
+ opacity: 0;
31
+ }
32
+ &:has(*:placeholder-shown:not(:focus)) {
33
+ > span,
34
+ label {
35
+ font-size: inherit;
36
+ opacity: 50%;
37
+ }
38
+ }
39
+ }
40
+ /*
41
+ ```
42
+ The `:has(*:placeholder-shown:not(:focus))` trick allows this input state information to *propagate* to the parent level. This enables modern CSS to target inner float label (`<span>` or `<label>`) regardless of its position relative to the input field.
43
+
44
+ Historically, this was not possible: the float label had to be placed after the input field to be targeted using the `input:focus + label` selector.
45
+ <!--section--> */
46
+ label:has(input:not([type="checkbox"], [type="radio"], [type="range"]), textarea, select),
47
+ .has-float-label {
48
+ /* Default/fallback state */
49
+ > span,
50
+ label {
51
+ padding-inline-start: calc(1rem + 1px); /* match Pico's padding + border */
52
+ padding-block-start: 0.25rem;
53
+ opacity: 75%;
54
+ transition: all 0.25s;
55
+ }
56
+ input,
57
+ textarea,
58
+ select {
59
+ margin-block-start: 0; /* reset Pico */
60
+ padding-inline-start: 1rem; /* match Pico */
61
+ padding-block: 1.125rem 0.375rem; /* match Pico's total: 2 x 0.75rem = 1.5rem */
62
+
63
+ &::placeholder {
64
+ opacity: 100%;
65
+ transition: all 0.25s;
66
+ }
67
+ }
68
+
69
+ /* Enlarged state */
70
+ &:has(*:placeholder-shown:not(:focus)) {
71
+ > span,
72
+ label {
73
+ padding-block: 0.75rem; /* match Pico */
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,31 @@
1
+ label:has(input:not([type="checkbox"], [type="radio"], [type="range"]), textarea, select),
2
+ .has-float-label {
3
+ /* Default/fallback state */
4
+ > span,
5
+ label {
6
+ padding-inline-start: calc(1rem + 1px); /* match Pico's padding + border */
7
+ padding-block-start: 0.25rem;
8
+ opacity: 75%;
9
+ transition: all 0.25s;
10
+ }
11
+ input,
12
+ textarea,
13
+ select {
14
+ margin-block-start: 0; /* reset Pico */
15
+ padding-inline-start: 1rem; /* match Pico */
16
+ padding-block: 1.125rem 0.375rem; /* match Pico's total: 2 x 0.75rem = 1.5rem */
17
+
18
+ &::placeholder {
19
+ opacity: 100%;
20
+ transition: all 0.25s;
21
+ }
22
+ }
23
+
24
+ /* Enlarged state */
25
+ &:has(*:placeholder-shown:not(:focus)) {
26
+ > span,
27
+ label {
28
+ padding-block: 0.75rem; /* match Pico */
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,55 @@
1
+ /* Extends https://github.com/picocss/pico/blob/main/scss/content/_link.scss
2
+ <!--section:code-->
3
+ ```css */
4
+ a {
5
+ /* Use inline flex only if link contains an icon */
6
+ &:has(> i) {
7
+ display: inline-flex;
8
+ gap: 0.375ch; /* =3/8 */
9
+ overflow-y: clip; /* to work in pair with text-underline-offset in Safari */
10
+ }
11
+ > i {
12
+ font-style: normal;
13
+ float: left; /* ✅ Chrome ❌ Safari */
14
+ text-underline-offset: -2em; /* ❌ Chrome ✅ Safari - to clip it with overflow-y */
15
+
16
+ /* Favicons */
17
+ > img {
18
+ height: 1.25em;
19
+ margin-block: calc(-0.25em / 2);
20
+ display: inline-block; /* for Tailwind CSS Typography */
21
+ }
22
+
23
+ /* Font Awesome */
24
+ &[class^="fa-"],
25
+ &[class*=" fa-"] {
26
+ line-height: inherit;
27
+ --fa-width: auto;
28
+ }
29
+ &.fa-lg {
30
+ line-height: normal;
31
+ }
32
+ }
33
+ }
34
+ /*```
35
+ > **PRO-TIP** for 11ty: https://blades.ninja/build-awesome-11ty/processors/#auto-link-favicons
36
+
37
+ <!--section:docs,summary-->
38
+
39
+ Use Blades' `<i>`-helper to wrap emojis, favicons, or simply drop Font Awesome icons inside links. It automatically handles sizing and alignment while preventing underline on icons.
40
+
41
+ <!--section:docs-->
42
+
43
+ Compare:
44
+
45
+ | Without Blades <hr class="lg"> | With Blades' `<i>`-helper <hr class="lg"> | Clean HTML without `<span>ning` <hr class="x2"> |
46
+ | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
47
+ | [🥷 Link with emoji](#) | [<i>🥷</i> Link with emoji](#) | `<a><i>🥷</i> Text</a>` |
48
+ | [![](https://www.google.com/s2/favicons?domain=any.digital&sz=64) Multi-line link <br> with favicon](#) | [<i>![](https://www.google.com/s2/favicons?domain=any.digital&sz=64)</i> Multi-line link <br> with favicon](#) | `<a><i><img src="..."></i> Text</a>` |
49
+ | [<b class="fa-brands fa-github fa-lg"></b> Link with Font Awesome icon](#) | [<i class="fa-brands fa-github fa-lg"></i> Link with Font Awesome icon](#) | `<a><i class="fa-..."></i> Text</a>` |
50
+
51
+ ---
52
+
53
+ [How we made it ↗ &nbsp;<small>(on Codepen)</small>](https://codepen.io/editor/anydigital/pen/019d2b94-5616-75dc-a23e-e111869d5237){role=button .outline}
54
+
55
+ <!--section--> */
@@ -0,0 +1,55 @@
1
+ /* <!--section:code-->
2
+ ```css */
3
+ table.responsive,
4
+ .breakout > table:not(.does-not-exist),
5
+ .breakout-all > table:not(.does-not-exist) {
6
+ /* Center horizontally */
7
+ margin-left: 50%;
8
+ transform: translateX(-50%);
9
+
10
+ /* Let them full-bleed */
11
+ width: max-content;
12
+ min-width: auto;
13
+ max-width: 100vw;
14
+ padding-inline: 7.5%;
15
+
16
+ /* Let them scroll */
17
+ display: block;
18
+ overflow-x: auto;
19
+ -webkit-overflow-scrolling: touch; /* Smooth scroll for iOS */
20
+
21
+ th,
22
+ td {
23
+ padding-inline-start: 0;
24
+ }
25
+ }
26
+ /*```
27
+ <!--#TODO:css-blade-->
28
+ Soft-increase selector specificity trick:
29
+
30
+ `table:not(.does-not-exist)` (inspired by postcss) is used here to increase specificity against selectors like `&:is(table, .table)`
31
+
32
+ <!--section:docs,summary-->
33
+
34
+ `<table class="responsive">` allows a table to full-bleed and scroll on mobile.
35
+
36
+ <!--section:docs-->
37
+
38
+ | Term | Description <hr class="x2"> | Link |
39
+ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
40
+ | Responsive design | Approach to web design that aims to make web pages render well on a variety of devices and window or screen sizes from minimum to maximum display size to ensure usability and satisfaction. | https://en.wikipedia.org/wiki/Responsive_web_design |
41
+
42
+ {.responsive}
43
+
44
+ ---
45
+
46
+ Tables inside https://blades.ninja/css/breakout/ are responsive by default.
47
+
48
+ Living examples:
49
+
50
+ - https://any.digital/insights/ai-ide/
51
+ - https://any.digital/insights/css-frameworks/
52
+ - https://any.digital/insights/ssg/
53
+ - https://blades.ninja/build-awesome-11ty/#min-starters
54
+
55
+ <!--section--> */
package/blades.gemspec ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "blades"
5
+ spec.version = "0.28.0-alpha.2"
6
+ spec.authors = ["Anton Staroverov"]
7
+
8
+ spec.summary = "Framework-agnostic CSS utilities and single-file Liquid 'blades' for modern web development."
9
+ spec.homepage = "https://github.com/anyblades/blades"
10
+ spec.license = "MIT"
11
+
12
+ spec.files = Dir.glob("{_includes,assets}/**/*")
13
+ # puts "spec.files: #{spec.files.inspect}"
14
+
15
+ spec.add_runtime_dependency "jekyll", ">= 3.5", "< 5.0"
16
+ end
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@anyblades/blades",
3
+ "version": "0.28.0-alpha.2",
4
+ "description": "Framework-agnostic CSS utilities and single-file Liquid 'blades' for modern web development.",
5
+ "style": "./assets/blades.css",
6
+ "exports": {
7
+ ".": "./src/blades.css",
8
+ "./core": "./src/blades.core.css",
9
+ "./theme": "./src/blades.theme.css",
10
+ "./float-label": "./src/float-label.css",
11
+ "./unreduce-motion": "./src/_unreduce-motion.css"
12
+ },
13
+ "scripts": {
14
+ "postcss": "postcss './src/!(_)*.css' --dir ./assets",
15
+ "build": "npm run postcss -- --no-map",
16
+ "start": "npm run postcss -- --watch",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/anyblades/blades.git"
22
+ },
23
+ "keywords": [
24
+ "css",
25
+ "utilities",
26
+ "helpers",
27
+ "atomic",
28
+ "cdn"
29
+ ],
30
+ "author": "Anton Staroverov",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "postcss": "^8.4.33",
34
+ "postcss-cli": "^11.0.0",
35
+ "postcss-import": "^16.1.1",
36
+ "prettier-plugin-jinja-template": "^2.1.0"
37
+ }
38
+ }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ plugins: {
3
+ "postcss-import": {},
4
+ },
5
+ };
package/src/_code.css ADDED
@@ -0,0 +1,45 @@
1
+ /* <!--section:docs-->
2
+ ### Code
3
+ Extends https://github.com/picocss/pico/blob/main/scss/content/_code.scss
4
+ ```css */
5
+ pre {
6
+ padding: 1rem 1.5rem;
7
+ padding-inline-end: 2rem;
8
+
9
+ @media screen and (max-width: 767px) {
10
+ border-radius: 0;
11
+ }
12
+ }
13
+
14
+ code {
15
+ /* Code block caption via data-attr (to display filename, etc.) */
16
+ &[data-caption] {
17
+ &::before {
18
+ content: attr(data-caption);
19
+ display: block;
20
+ margin-bottom: 1rem;
21
+ opacity: 50%;
22
+ font-style: italic;
23
+ }
24
+ }
25
+
26
+ &:where(pre > *) {
27
+ padding: 0;
28
+ }
29
+ }
30
+
31
+ /*** Extends https://github.com/PrismJS/prism/blob/master/plugins/treeview/prism-treeview.css ***/
32
+ .token.treeview-part {
33
+ .entry-line {
34
+ width: 2.5em !important;
35
+ opacity: 25%;
36
+ }
37
+ .entry-name:last-child {
38
+ opacity: 50%;
39
+
40
+ &::before {
41
+ display: none !important;
42
+ }
43
+ }
44
+ }
45
+ /*``` <!--section--> */
@@ -0,0 +1,47 @@
1
+ /* Extends https://github.com/picocss/pico/blob/main/scss/layout/
2
+ <!--section:docs-intro-->
3
+
4
+ Global styles:
5
+ ```css */
6
+ html {
7
+ /* Prevent horizontal overflow and scrolling, modern way. */
8
+ overflow-x: clip;
9
+ }
10
+ body {
11
+ /* Ensure `body` takes at least the full height of the viewport (using dynamic viewport height for better mobile support). */
12
+ min-height: 100dvh;
13
+ }
14
+ /*```
15
+ <!--section:docs-->
16
+
17
+ ### Auto-columns
18
+ ```css */
19
+ .columns,
20
+ [data-is-toc] > ul,
21
+ [data-is-toc] > ol {
22
+ columns: 30ch auto; /* 2 cols max for 65ch container */
23
+
24
+ /* Avoid breaking inside elements, such as nested lists */
25
+ > * {
26
+ break-inside: avoid;
27
+ }
28
+ }
29
+ /*```
30
+
31
+ Table of contents (`[data-is-toc]`) has auto-columns by default.
32
+
33
+ ### Jump to top
34
+ ```css */
35
+ [data-jump-to="top"] {
36
+ position: fixed;
37
+ bottom: 0;
38
+ right: 0;
39
+ padding-top: 50vh;
40
+ opacity: 25%;
41
+
42
+ &:hover {
43
+ opacity: 75%;
44
+ }
45
+ }
46
+ /*```
47
+ <!--section--> */