An experiment in cleaning up CSS by just avoiding dis-features and focusing on flexbox and CSS grids.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
fsckcss/src/demos/Pinterest.svelte

185 lines
3.2 KiB

<script>
import { link } from 'svelte-spa-router';
import Icon from '../components/Icon.svelte';
import CodeView from '../components/CodeView.svelte';
import { holder } from '../../lib/imgholder.js';
let samples = [1,2,3];
let lanes = [1,2,3,4,5];
let pin_sizes = [240, 180, 250, 580];
export let thumbnail = false;
const random_select = (from_array) => {
let min = Math.ceil(0);
let max = Math.floor(from_array.length);
let index = Math.floor(Math.random() * (max - min) + min);
return from_array[index];
}
const random_sample = (from_array, count) => {
let result = [];
for(let i = 0; i < count; i++) {
result.push(random_select(from_array));
}
return result;
}
</script>
<style>
:root {
--pin-red: #e60023;
}
content {
border: 1px solid #ddd;
display: flex;
flex-direction: column;
flex: flex-grow;
flex-basis: 100%;
grid-column: 1/3;
padding: 1rem;
}
header {
display: flex;
width: 100%;
flex-direction: row;
}
header nav {
display: flex;
flex: 1;
}
header nav input {
width: 100%;
}
header nav button {
border-radius: 30px;
background-color: var(--color-bg-secondary);
border: unset;
color: var(--color-text);
padding-left: 1rem;
padding-right: 1rem;
}
header nav button#signup {
background-color: var(--pin-red);
color: var(--color-bg);
}
header nav a {
color: var(--text-color);
}
header logo {
color: var(--pin-red);
display: flex;
font-size: 1.2em;
}
header left {
display: flex;
justify-content: space-evenly;
padding: 1em;
flex: 2;
}
header input {
border-radius: 30px;
flex: 3;
padding: 1rem;
}
profile {
display: flex;
flex-direction: row;
width: 100%;
justify-content: center;
}
profile info {
margin-right: 2em;
}
profile h1 {
margin-bottom: unset;
font-size: 3em;
}
profile p {
margin-bottom: 0.5rem;
margin-top: 0.5rem;
}
pins {
display: flex;
flex-direction: row;
}
pins lane figure {
margin: 0.5rem;
}
pins lane figure img {
border-radius: 15px;
}
pins lane {
display: flex;
flex-direction: column;
}
</style>
<content>
<header>
<nav>
<left>
<logo><Icon name="pinterest" color="var(--color)" /> Pinterest</logo>
<a>Today</a>
<a>Explore</a>
</left>
<input placeholder="Search">
<ul>
<li><button>Log In</button></li>
<li><button id="signup">Sign Up</button></li>
</ul>
</nav>
</header>
{#if !thumbnail}
<profile>
<info>
<h1>Vincent van Gogh</h1>
<p>Collection by A Person</p>
<p><b>420</b> Pins • <b>3.59k</b> Followers</p>
<p>"I dream my painting and I paint my dream." ~ Vincent van Gogh
</info>
<figure>
<img alt="Zed's Face" src="{ holder(128,128) }">
</figure>
</profile>
<pins>
{#each lanes as lane}
<lane>
{#each random_sample(pin_sizes, 10) as height}
<figure>
<img alt="Van Gogh Art" src={ holder(240, height) }>
<figcaption>Something about Van Gogh {height} high.</figcaption>
</figure>
{/each}
</lane>
{/each}
</pins>
{/if}
</content>
<CodeView source="/code/Pinterest" />