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

Fix visual layout #5

Merged
merged 1 commit into from
Sep 21, 2023
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
80 changes: 0 additions & 80 deletions src/app.css

This file was deleted.

4 changes: 4 additions & 0 deletions src/assets/green_check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/red_cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 92 additions & 41 deletions src/pages/Contrast.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,36 @@
<p>
This is primarily a tool for the Warp team to check the contrast between the
various text colours and background colours. Currently only for FINN
colours.

The colour contrast for small and normal text must be minimun <strong>4.5 : 1</strong>.
colours. The colour contrast for small and normal text must be minimun <strong
>4.5 : 1</strong
>.
</p>

<!-- Checkbox
<div class="mt-32">
<input
type="checkbox"
id="accessibilityOnly"
name="accessibilityOnly"
value="checkedValue"
/>
<label for="accessibilityOnly">Only accessible colour combinations</label>

</div>
-->

{#if backgroundTokens.length === 0}
<p>No background colours loaded</p>
{:else}
{#each backgroundTokens as background (background.name)}
<h2 class="mt-56 text-ml">{background.name}</h2>

<div class="flex">
<div class="flex mt-8">
<div
class="colorsquare w-24 h-24 rounded-4 border mr-8"
class="colorsquare w-24 h-24 rounded-4 mr-8"
style="background-color: {background.value};"
/>
<p>{background.colorName}, {background.value}</p>
<p> {background.colorName}</p>
</div>

<div>
Expand All @@ -98,16 +111,17 @@
{:else}
<!-- Table for foreground colours -->
<table
class="mt-24 mb-56 border-spacing-x-24"
style="border-collapse: separate;"
class="mt-32 border-spacing-x-24"
style="border-collapse: collapse;"
>
<!-- Column headers -->
<thead>
<tr class="text-left">
<tr class="text-left mb-48">
<th>Text colour name</th>
<th>Colour</th>
<th>Example</th>
<th>Contrast</th>
<th>Usage</th>
<th>Accessible</th>
</tr>
</thead>

Expand All @@ -116,49 +130,50 @@
{#each foregroundTokens as token (token.name)}
<tr>
<!-- Name -->
<td>{token.name}</td>
<td>
<p class="mt-6">{token.name}</p>
</td>
<!-- Colour -->

<td>
<div class="flex mt-8">
<div class="flex items-center">
<div
class="colorsquare w-24 h-24 rounded-4 border mr-8 flex justify-center items-center"
style="background-color: {background.value};"
>
<div
class="w-16 h-16 rounded-2"
style="background-color: {token.value};"
/>
</div>

<p>{token.colorName}</p>
class="w-24 h-24 mr-8 rounded-2"
style="background-color: {token.value};"
/>
<p class="mt-6">{token.colorName}</p>
</div>
</td>
<!-- Example -->
<td>
<div
class="mt-2 px-8 colorsquare border rounded-4 flex justify-center items-center h-24"
class="h-48 w-128 colorsquare rounded-4 flex justify-center items-center"
style="background-color: {background.value};"
>
<p class="mb-0" style="color: {token.value};">ABC abc</p>
<p class="mb-2" style="color: {token.value};">ABC abc</p>
</div>
</td>
<!-- Contrast -->
<td class="text-right">
<td class="text-left">
<p class="mt-6">
{checkColors(token.value, background.value).contrast} : 1
</p>
</td>
<!-- Usage -->
<td>
<!-- Evaluation OK or not -->
{#if parseFloat(checkColors(token.value, background.value).contrast) > 4.5}
<div class="px-8 s-bg-positive s-text-inverted rounded-4 flex justify-center items-center h-24" >
<p class="mt-8">OK</p>
</div>
{:else}
<div class="px-8 s-bg-negative s-text-inverted rounded-4 flex justify-center items-center h-24">
<p class="mt-8">Not OK</p>
</div>
{/if}
<!-- Accessible -->
<td class="flex justify-center items-center">
<!-- Evaluation OK or not -->
{#if parseFloat(checkColors(token.value, background.value).contrast) > 4.5}
<img
class="h-24 mt-10"
src="../src/assets/green_check.svg"
alt="Green check"
/>
{:else}
<img
class="h-24 mt-10"
src="../src/assets/red_cross.svg"
alt="Red cross"
/>
{/if}
</td>
</tr>
{/each}
Expand All @@ -180,7 +195,7 @@
main {
padding: 16px;
margin: auto;
max-width: 700px;
max-width: 900px;
height: 100%;
display: flex;
flex-direction: column;
Expand All @@ -191,10 +206,46 @@
}

table {
margin-left: -24px; /* Adjust to match your border-spacing value */
/* margin-left: -24px; Adjust to match your border-spacing value */
}

td,
th {
padding-right: 24px; /* Space to the right of the cell content */
padding-left: 24px; /* Space to the right of the cell content */
padding-top: 12px;
padding-bottom: 12px;
vertical-align: middle;
}

tr {
border-bottom: 1px solid #000;
border-color: var(--w-s-color-border);
padding-top: 12px;
padding-bottom: 12px;
}

tr:last-child {
border-bottom: none;
}

td:first-child {
td:first-child,
th:first-child {
padding-left: 0;
}

td:last-child,
th:last-child {
padding-right: 0;
}

input[type="checkbox"] {
width: 16px;
height: 16px;
}

input[type="checkbox"],
label {
vertical-align: middle;
}
</style>