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 flex-grid-template and image-object-fit for Atomic CSS #17

Merged
merged 3 commits into from
Nov 16, 2022
Merged
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
55 changes: 55 additions & 0 deletions css/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Flex grid
*/
.flex-grid-template {
--grid-gap-x:30px;
--grid-gap-y:30px;
--grid-col:3;
/* calculate new width */
--grid-gap-x-total:calc(var(--grid-gap-x) * (var(--grid-col) - 1));
--grid-space-each:calc(var(--grid-gap-x-total) / var(--grid-col));
display:flex;
flex-wrap:wrap;
gap:var(--grid-gap-y) var(--grid-gap-x);
}

.flex-grid-template > * {
width:calc(100% / var(--grid-col) - var(--grid-space-each));
}

@media only screen and (max-width:768px) {
.flex-grid-template {
--grid-col:2;
}
}
@media only screen and (max-width:480px) {
.flex-grid-template {
--grid-col:1;
}
}
/**
* Background object fit
*/
.img-wrapper-cover > img {
object-position:center center;
height:100%;
width:100%;
min-height:100%;
min-width:100%;
max-height:100%;
max-width:100%;
display:block;
object-fit:cover;
}

.img-wrapper-contain > img {
object-position:center center;
height:100%;
width:100%;
min-height:100%;
min-width:100%;
max-height:100%;
max-width:100%;
display:block;
object-fit:contain;
}
3 changes: 2 additions & 1 deletion scss/_config.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
//$breakpoints: (
// "lg": 1280px,
// "md": 1024px,
// "sm": 480px,
// "sm": 768px,
// "xs": 480px,
//);

// vertical spacing
Expand Down
3 changes: 2 additions & 1 deletion scss/_defs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ $variables: ();
$breakpoints: (
"lg": 1180px,
"md": 1024px,
"sm": 480px,
"sm": 768px,
"xs": 480px,
);

// font sizes
Expand Down
58 changes: 58 additions & 0 deletions scss/extra.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@import 'helpers';

/**
* Flex grid
*/
.flex-grid-template {
--grid-gap-x: 30px;
--grid-gap-y: 30px;
--grid-col: 3;

/* calculate new width */
--grid-gap-x-total: calc(var(--grid-gap-x) * (var(--grid-col) - 1));
--grid-space-each: calc(var(--grid-gap-x-total) / var(--grid-col));

display: flex;
flex-wrap: wrap;
gap: var(--grid-gap-y) var(--grid-gap-x);
}

.flex-grid-template > * {
width: calc(100% / var(--grid-col) - var(--grid-space-each));
}

@media only screen and (max-width: map-get($breakpoints, "sm")) {
.flex-grid-template {
--grid-col: 2;
}
}

@media only screen and (max-width: map-get($breakpoints, "xs")) {
.flex-grid-template {
--grid-col: 1;
}
}

/**
* Background object fit
*/
@mixin img-object-fit {
object-position: center center;
height: 100%;
width: 100%;
min-height: 100%;
min-width: 100%;
max-height: 100%;
max-width: 100%;
display: block;
}

.img-wrapper-cover > img {
@include img-object-fit;
object-fit: cover;
}

.img-wrapper-contain > img {
@include img-object-fit;
object-fit: contain;
}