refactor: ♻️ make better use of css grid and add responsiveness
This commit is contained in:
parent
262ed4d526
commit
e99d6a2eaf
1 changed files with 45 additions and 23 deletions
|
@ -1,63 +1,85 @@
|
|||
<ul class="character-colors">
|
||||
<li class="color" webc:for="color of colors">
|
||||
<div class="color-box" @attributes="({ style: `background-color: ${color.value}`})"></div>
|
||||
<div class="content">
|
||||
<p class="heading" @text="color.name"></p>
|
||||
<p class="text" @text="color.value"></p>
|
||||
</div>
|
||||
<p class="heading" @text="color.name"></p>
|
||||
<p class="value" @text="color.value"></p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<style>
|
||||
.character-colors {
|
||||
--color-box-size: 5.5em;
|
||||
--columns: repeat(auto-fit, minmax(15em, 1fr));
|
||||
--clearance: 0.25rem;
|
||||
--color-box-size: calc(var(--clearance) * 14);
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(8em, 1fr));
|
||||
gap: 1em;
|
||||
grid-template-columns: var(--columns);
|
||||
gap: 0.75em;
|
||||
|
||||
margin-block: 2em;
|
||||
padding: 0;
|
||||
|
||||
@media (min-width: 35em) {
|
||||
--color-box-size: 5em;
|
||||
--columns: repeat(auto-fit, minmax(8em, 1fr));
|
||||
}
|
||||
|
||||
& .color {
|
||||
--areas: 'color heading' 'color value';
|
||||
--rows: repeat(2, 1fr);
|
||||
--columns: var(--color-box-size) 1fr;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: subgrid;
|
||||
grid-template-rows: 1.5fr 1fr;
|
||||
grid-template-areas: var(--areas);
|
||||
grid-template-rows: var(--rows);
|
||||
grid-template-columns: var(--columns);
|
||||
|
||||
background-color: var(--clr-color-box-background);
|
||||
|
||||
border: var(--border-thin) solid var(--clr-box-border);
|
||||
border-radius: 0.5em;
|
||||
|
||||
overflow: hidden;
|
||||
overflow: clip;
|
||||
|
||||
@media (min-width: 35em) {
|
||||
--areas: 'color' 'heading' 'value';
|
||||
--rows: var(--color-box-size) 1fr auto;
|
||||
--columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
& .content {
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
justify-content: space-between;
|
||||
gap: 0.25em;
|
||||
& .color-box {
|
||||
grid-area: color;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
& p {
|
||||
margin-block: 0;
|
||||
& .heading,
|
||||
& .value {
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
padding-block: calc(var(--clearance) * 2);
|
||||
padding-inline: calc(var(--clearance) * 2);
|
||||
}
|
||||
|
||||
& .heading {
|
||||
flex: 1 0 auto;
|
||||
grid-area: heading;
|
||||
align-self: start;
|
||||
|
||||
font-size: 0.625em;
|
||||
line-height: 1.2;
|
||||
color: var(--clr-heading-data);
|
||||
text-transform: uppercase;
|
||||
text-align: left;
|
||||
|
||||
}
|
||||
|
||||
& .text {
|
||||
flex: 0 0 auto;
|
||||
& .value {
|
||||
grid-area: value;
|
||||
align-self: end;
|
||||
|
||||
font-size: 0.75em;
|
||||
margin-inline: 0;
|
||||
|
||||
padding-block: 0 calc(var(--clearance) * 2);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue