starting work on abstracting card design
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
---
|
||||
import { JSDOM } from 'jsdom'
|
||||
import Container from './Container.astro'
|
||||
|
||||
const language = Astro.props['data-language'] ?? 'text'
|
||||
|
||||
const html = await Astro.slots.render('default')
|
||||
|
||||
console.log(html)
|
||||
|
||||
const rawCode = new JSDOM(html).window.document.body.textContent
|
||||
---
|
||||
|
||||
<pre {...Astro.props}><slot /></pre>
|
||||
|
||||
{language === 'astro' && <Container set:html={rawCode} />}
|
||||
@@ -3,14 +3,46 @@ import Palette from '../../components/meta/Palette.astro'
|
||||
|
||||
import ArticleCard from '../../components/ArticleCard.astro'
|
||||
|
||||
# Meta / Design
|
||||
# Meta > Design
|
||||
|
||||
In questa pagina tento di spiegare come funziona il design di questo sito.
|
||||
In questa pagina tento di spiegare come funziona il design di questo sito. I blocchi di codice con sfondo arancione chiaro sono esempi di codice Astro e sotto hanno un'anteprima del risultato _generata automaticamente_. Ad esempio
|
||||
|
||||
```astro
|
||||
<p>Questo è un paragrafo</p>
|
||||
```
|
||||
|
||||
## Card
|
||||
|
||||
Le card sono uno dei componenti più importanti di questo sito. Sono utilizzate per mostrare i post, i progetti e le pagine. Ecco alcuni esempi per dare un'idea
|
||||
|
||||
### Esempio di base
|
||||
|
||||
Una card semplice ha un titolo ed una descrizione.
|
||||
|
||||
```astro
|
||||
<div class="card" style="--card-base: var(--guide-base); max-width: 25rem;">
|
||||
<div class="title">Titolo</div>
|
||||
<div class="text">
|
||||
Descrizione lorem ipsum dolor sit amet consectetur
|
||||
adipisicing elit. Aspernatur, labore?
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
### Variante grande
|
||||
|
||||
Le card possono essere di dimensioni diverse. Questa è una card grande.
|
||||
|
||||
```astro
|
||||
<div class="card large" style="--card-base: lightgreen; max-width: 25rem;">
|
||||
<div class="title">Titolo</div>
|
||||
<div class="text">
|
||||
Descrizione lorem ipsum dolor sit amet consectetur
|
||||
adipisicing elit. Aspernatur, labore?
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
### Lista di articoli
|
||||
|
||||
Una lista di articoli è composta da più card, ognuna delle quali rappresenta un articolo. Ogni card ha un titolo, una descrizione e una lista di tag.
|
||||
|
||||
@@ -4,13 +4,31 @@ import BaseLayout from '../../layouts/BaseLayout.astro'
|
||||
import Header from '../../components/Header.astro'
|
||||
import Footer from '../../components/Footer.astro'
|
||||
|
||||
import { Content } from '../../content/meta/design.mdx'
|
||||
import CodeBlockPreview from '../../components/meta/CodeBlockPreview.astro'
|
||||
|
||||
import { Content, getHeadings } from '../../content/meta/design.mdx'
|
||||
|
||||
const headings = getHeadings()
|
||||
---
|
||||
|
||||
<BaseLayout {...Astro.props} pageName="design">
|
||||
<Header />
|
||||
<aside>
|
||||
<nav>
|
||||
<h2>Indice</h2>
|
||||
<ul>
|
||||
{
|
||||
headings.map(heading => (
|
||||
<li style={{ '--depth': heading.depth }}>
|
||||
<a href={`#${heading.slug}`}>{heading.text}</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
<main class="text-content center">
|
||||
<Content />
|
||||
<Content components={{ pre: CodeBlockPreview }} />
|
||||
</main>
|
||||
<Footer />
|
||||
</BaseLayout>
|
||||
|
||||
@@ -318,3 +318,61 @@ $news-accent-bg: #f8e8b1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cards
|
||||
//
|
||||
|
||||
.card {
|
||||
display: grid;
|
||||
|
||||
--card-base-internal: var(--card-base, #f8f8f8);
|
||||
|
||||
background: var(--card-base-internal);
|
||||
color: color-mix(in srgb, var(--card-base-internal), #000 80%);
|
||||
|
||||
@include neo-brutalist-card($size: 3px, $offset: 9px);
|
||||
|
||||
row-gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
|
||||
// Variants
|
||||
|
||||
&.large {
|
||||
padding: 2rem;
|
||||
|
||||
@include neo-brutalist-card($size: 4px, $offset: 8px);
|
||||
|
||||
row-gap: 1rem;
|
||||
|
||||
& > .title {
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
& > .text {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
// Child Items
|
||||
|
||||
& > .title {
|
||||
color: color-mix(in srgb, var(--card-base-internal), #000 75%);
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
& > .text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
& > .tags {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #555;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-4
@@ -27,10 +27,13 @@ $screen-desktop-min: 1024px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
@@ -93,10 +96,10 @@ a {
|
||||
|
||||
body {
|
||||
// for the header spacing
|
||||
padding-top: 6rem;
|
||||
// padding-top: 6rem;
|
||||
|
||||
display: grid;
|
||||
grid-template-rows: 1fr auto;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
|
||||
header {
|
||||
z-index: 10;
|
||||
@@ -105,8 +108,10 @@ body {
|
||||
border-bottom: $border-large;
|
||||
background: $header-bg;
|
||||
|
||||
grid-column: 1 / -1;
|
||||
|
||||
top: 0;
|
||||
position: fixed;
|
||||
position: sticky;
|
||||
width: 100%;
|
||||
|
||||
display: flex;
|
||||
@@ -143,6 +148,8 @@ body {
|
||||
}
|
||||
|
||||
footer {
|
||||
z-index: 10;
|
||||
|
||||
min-height: 6rem;
|
||||
border-top: $border-large;
|
||||
background: $footer-bg;
|
||||
|
||||
+85
-5
@@ -417,8 +417,84 @@
|
||||
}
|
||||
|
||||
.design {
|
||||
grid-template-columns: 2fr 10fr;
|
||||
|
||||
@media screen and (max-width: 1400px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
aside {
|
||||
margin: 1rem;
|
||||
padding: 1rem;
|
||||
|
||||
@include neo-brutalist-card();
|
||||
|
||||
background: #f0f0f0;
|
||||
|
||||
align-self: start;
|
||||
position: sticky;
|
||||
top: 7rem;
|
||||
height: calc(100dvh - 8rem - 6rem);
|
||||
|
||||
nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
li {
|
||||
padding-left: calc((var(--depth) - 1) * 1rem);
|
||||
|
||||
a {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
|
||||
color: #444;
|
||||
|
||||
&:hover {
|
||||
color: #666;
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1400px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
main {
|
||||
justify-self: center;
|
||||
|
||||
// trick to fix anchor links with sticky header
|
||||
& > h1,
|
||||
& > h2,
|
||||
& > h3,
|
||||
& > h4 {
|
||||
padding-top: 7rem;
|
||||
margin-top: -7rem;
|
||||
}
|
||||
}
|
||||
|
||||
pre[data-language='astro'] {
|
||||
--code-bg: #fff7ef;
|
||||
|
||||
width: 100%;
|
||||
max-width: 46rem;
|
||||
}
|
||||
|
||||
.container {
|
||||
@@ -430,21 +506,25 @@
|
||||
z-index: 1;
|
||||
|
||||
&.large {
|
||||
min-width: calc(100vw - 4rem);
|
||||
min-width: calc(100% - 4rem);
|
||||
}
|
||||
|
||||
&:not(.large) {
|
||||
& > .content {
|
||||
display: grid;
|
||||
place-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
& > .content {
|
||||
padding: 2rem;
|
||||
|
||||
// display: grid;
|
||||
// place-content: center;
|
||||
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
// label in the top left corner
|
||||
&::before {
|
||||
content: 'Result';
|
||||
content: 'Preview';
|
||||
position: absolute;
|
||||
|
||||
bottom: 100%;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
pre,
|
||||
code {
|
||||
background: #f0f0f0 !important;
|
||||
background: var(--code-bg, #f0f0f0) !important;
|
||||
|
||||
font-family: 'Source Code Pro', monospace;
|
||||
font-weight: 400;
|
||||
@@ -75,7 +75,15 @@
|
||||
|
||||
p {
|
||||
line-height: 1.75;
|
||||
margin: 0.5rem auto;
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@include geometric-headings;
|
||||
|
||||
Reference in New Issue
Block a user