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

Updated to add an example tab to showcase the size #4

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
45 changes: 44 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
"@sveltejs/adapter-vercel": "next",
"@sveltejs/kit": "next",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"cssnano": "^5.0.12",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.1",
Expand All @@ -31,14 +33,13 @@
"svelte-preprocess": "^4.9.4",
"svimg": "^1.1.0",
"tslib": "^2.3.1",
"typescript": "^4.4.3",
"@sveltejs/adapter-vercel": "next",
"cssnano": "^5.0.12"
"typescript": "^4.4.3"
},
"type": "module",
"dependencies": {
"@floating-ui/dom": "^0.1.4",
"chart.js": "^3.4.0",
"chartjs-plugin-crosshair": "^1.2.0"
"chartjs-plugin-crosshair": "^1.2.0",
"svelte-watch-resize": "^1.0.3"
}
}
69 changes: 69 additions & 0 deletions src/components/Example.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<script>
import { fluidSize, maxSize, minSize, relativeSizePx, rootFontSize } from '../modules/form/store';
import { calculateSizeValue } from '../modules/tracker/utils';

export let text;

// Determine the document width on resize of the window
let screenWidth = document.documentElement.clientWidth
const handleResize = ()=> {
screenWidth = document.documentElement.clientWidth
}

// Compute the font-size
$: sizeValue = calculateSizeValue(screenWidth, $fluidSize, $relativeSizePx, $minSize, $maxSize);
</script>

<svelte:window on:resize={handleResize}/>

<section class="example">

<!-- Placeholder for future slider to simulate various viewport widths -->

<aside class="example__msg">
The current viewport <code>width</code> is
<strong class="example__msg--vp">{screenWidth}px</strong>.
Therefor the computed <code>font-size</code> of the text below is
<strong class="example__msg--fs"> {sizeValue}px</strong>.
</aside>

<div
class="example__txt"
style="--clamped-size: {text.substring(0, text.length - 1)}"
contenteditable="true"
>
Hello world (this text is editable)
</div>

</section>


<style>
.example__msg {
font-family: var(--font-family-primary);
text-align: left;
}

.example__msg--vp {
color: var(--color-secondary);
}

.example__msg--fs {
color: var(--color-primary);
}

.example__txt {
margin-top: var(--spacing-2);
padding: var(--spacing-1);
font-size: var(--clamped-size);
border: 2px solid var(--color-secondary-faded);
border-radius: var(--spacing-n4);

&:focus {
background-color: var(--color-secondary-faded);
color: var(--color-secondary);
outline: none;
border-color: var(--color-secondary-tint);
}
}
</style>
3 changes: 1 addition & 2 deletions src/components/Snippet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<pre
class="snippet__wrapper">
<code class="snippet__code">

{text}
</code>
</pre>
Expand All @@ -38,7 +37,7 @@
border-radius: 8px;
color: var(--color-gray-light);
max-width: 100%;
ovverflow: auto;
overflow: auto;

@media (--mq-desktop-min) {
display: flex;
Expand Down
17 changes: 12 additions & 5 deletions src/modules/tabs/Tabs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,26 @@
text-align: center;
display: block;
border: 2px solid currentColor;
border-radius: var(--spacing-n1) 0 0 var(--spacing-n1);

flex-grow: 1;

@media (--mq-mobileLandscape-min) {
flex-grow: initial;
min-width: calc(2 * var(--spacing-4));
padding: var(--spacing-n1) var(--spacing-1);
}
}

.tab__button + .tab__button {
border-radius: 0 var(--spacing-n1) var(--spacing-n1) 0;
margin-left: -2px;
&:first-child {
border-radius: var(--spacing-n1) 0 0 var(--spacing-n1);
}

&:last-child {
border-radius: 0 var(--spacing-n1) var(--spacing-n1) 0;
}

&:not(:first-child) {
margin-left: -2px;
}
}

.tab__button--active {
Expand Down
5 changes: 4 additions & 1 deletion src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Legend from 'src/components/Legend.svelte';
import Snippet from 'src/components/Snippet.svelte';
import Stats from 'src/components/Stats.svelte';
import Example from 'src/components/Example.svelte';
import { clampValue, maxSize, minSize } from 'src/modules/form/store';
import { graphChangeEnd, graphChangeStart } from 'src/modules/graph/derived';
import AddValue from 'src/modules/tracker/AddValue.svelte';
Expand All @@ -17,7 +18,7 @@
</aside>

<section class="homepage__content">
<Tabs tabs={['Graph', 'Table']} let:activeTab>
<Tabs tabs={['Graph', 'Table', 'Example']} let:activeTab>
{#if activeTab === 0}
<Stats
minValue={$minSize}
Expand All @@ -26,6 +27,8 @@
end={$graphChangeEnd.x}
/>
<Graph />
{:else if activeTab === 2}
<Example text={$clampValue} />
{:else}
<AddValue />
<article class="homepage__wrapper">
Expand Down