Skip to content

Commit

Permalink
feat: new layout pattern: equal
Browse files Browse the repository at this point in the history
  • Loading branch information
vycke committed Oct 9, 2024
1 parent 84624db commit 4ed9d2d
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 3 deletions.
16 changes: 16 additions & 0 deletions feo.css
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@
display: flex;
}

.equal {
--layout-gap: 0;
--layout-align: center;
--layout-direction: row;
flex-direction: var(--layout-direction);
align-items: var(--layout-align);
gap: var(--layout-gap);
flex-wrap: nowrap;
width: 100%;
display: flex;
}

.equal > * {
flex: 1 1 0;
}

.fifty {
--layout-threshold: 0;
--layout-gap: 0;
Expand Down
2 changes: 1 addition & 1 deletion feo.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:11ty": "npx @11ty/eleventy && yarn css:docs"
},
"name": "feo-css",
"version": "5.2.3",
"version": "5.3.0",
"main": "feo.css",
"description": "A tiny CSS framework",
"repository": "https://github.com/vyckes/feo-css.git",
Expand Down
2 changes: 1 addition & 1 deletion public/feo.min.css

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions site/layouts/equal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
layout: base.njk
title: Equal
key: layouts
subkey: equal
---

Makes a wrapper fill the available space and makes all the children equal size within that space. Does not wrap.

## Implementation

```
<div class="equal">
...
</div>
```

## API

<div>
<table>
<thead>
<tr><th>Custom property</th><th>Default</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>--layout-gap</code></td><td><code>0</code></td><td>Sets the <code>gap</code> of the targeted element</tr>
<tr><td><code>--layout-align</code></td><td><code>center</code></td><td>Sets the <code>align-items</code> of the targeted element</tr>
<tr><td><code>--layout-direction</code></td><td><code>row</code></td><td>Sets the <code>flex-direction</code> of the targeted element</tr>
</tbody>
</table>
</div>

## Utility classes

<div>
<table>
<thead>
<tr><th>Class name</th><th>Required?</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>--gap-{z}</code></td><td></td><td>Controls the <code>--layout-gap</code> API</tr>
<tr><td><code>--column/--row</code></td><td></td><td>Controls the <code>--layout-direction</code> API</tr>
<tr><td><code>--start/--end/--center/--stretch</code></td><td></td><td>Controls the <code>--layout-align</code> API</tr>
</tbody>
</table>
</div>
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/** layout */
@import "layout/center.css" layer(layout);
@import "layout/cluster.css" layer(layout);
@import "layout/equal.css" layer(layout);
@import "layout/fifty.css" layer(layout);
@import "layout/flex.css" layer(layout);
@import "layout/grid.css" layer(layout);
Expand Down
21 changes: 21 additions & 0 deletions src/layout/equal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Makes a wrapper fill the available space
* Makes all children equal size in the available space
*/

.equal {
--layout-gap: 0;
--layout-align: center;
--layout-direction: row;

display: flex;
flex-direction: var(--layout-direction);
flex-wrap: nowrap;
align-items: var(--layout-align);
gap: var(--layout-gap);
width: 100%;
}

.equal > * {
flex: 1 1 0px;
}

0 comments on commit 4ed9d2d

Please sign in to comment.