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

Combination grid #7

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
14,144 changes: 5,133 additions & 9,011 deletions package-lock.json

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 @@ -24,7 +24,7 @@
"apca-w3": "^0.1.2",
"color-name-list": "^9.4.0",
"culori": "^2.0.3",
"jest": "^28.0.2",
"jest": "^27.5.1",
"nearest-color": "^0.4.4",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
Expand Down
9 changes: 7 additions & 2 deletions src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ a.button {

.button--inline {
border-radius: calc(var(--radius) / 2);
padding: 0 0.25rem;
padding: 0.15rem 0.25rem;
text-transform: lowercase;
line-height: 1;
font-variant: small-caps;
font-weight: 900;
letter-spacing: 0.05ch;
Expand Down Expand Up @@ -228,7 +229,11 @@ a.button {

fieldset {
border: 0;
margin-bottom: 0.5rem;
margin-bottom: 1rem;
}

fieldset:last-child {
margin-bottom: 0;
}

.fieldset-fields {
Expand Down
65 changes: 25 additions & 40 deletions src/lib/components/combinations/Combinations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
filteredCombinations,
previewedCombinationUid
} from '$lib/stores/combinations';
import GridFilter from './GridFilter.svelte';

const handlePreview = (uid: string) => {
$previewedCombinationUid =
Expand All @@ -19,47 +20,31 @@
$: colorCount = $colorEntries?.length || 0;
</script>

<div class="data-layout">
<div class="data-options-track">
<div class="combinations">
<!-- Using a keyed each here worsens performances as it causes layout shifts -->
{#each $filteredCombinations as { uid, bgName, fgName, contrast, simulatedContrasts }}
<Combination
{uid}
{bgName}
{fgName}
{contrast}
{simulatedContrasts}
onPreview={handlePreview}
/>
{:else}
{#if colorCount > 1}
<div class="data-options form">
<ColorFilter />
<ContrastTypeFilter />
<ContrastFilter />
<BlindnessFilter />
<LuminosityFilter />
</div>
{/if}
</div>

<div class="list">
<!-- Using a keyed each here worsens performances as it causes layout shifts -->
{#each $filteredCombinations as { uid, bgName, fgName, contrast, simulatedContrasts }}
<Combination
{uid}
{bgName}
{fgName}
{contrast}
{simulatedContrasts}
onPreview={handlePreview}
/>
<p>
There is no color combination matching the selected
filters.
<br />
Try adding more colors to your palette or changing filters.
</p>
{:else}
{#if colorCount > 1}
<p>
There is no color combination matching the
selected filters.
<br />
Try adding more colors to your palette or changing
filters.
</p>
{:else}
<p>
Add colors to your palette to try color
combinations.
</p>
{/if}
{/each}
</div>
<p>
Add colors to your palette to try color combinations.
</p>
{/if}
{/each}
</div>

<style>
Expand All @@ -71,7 +56,7 @@
contain: layout;
}

.list {
.combinations {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(22ch, 1fr));
gap: 1rem;
Expand Down
15 changes: 15 additions & 0 deletions src/lib/components/combinations/Filters.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
import BlindnessFilter from './BlindnessFilter.svelte';
import ContrastFilter from './ContrastFilter.svelte';
import ContrastTypeFilter from './ContrastTypeFilter.svelte';
import GridFilter from './GridFilter.svelte';
import LuminosityFilter from './LuminosityFilter.svelte';
</script>

<div class="data-options form">
<ContrastTypeFilter />
<ContrastFilter />
<GridFilter />
<BlindnessFilter />
<LuminosityFilter />
</div>
Loading