Skip to content

Commit

Permalink
Merge pull request #2 from WickyNilliams/feature/polish-and-cleanup
Browse files Browse the repository at this point in the history
cleanup and polish
  • Loading branch information
WickyNilliams authored Mar 25, 2024
2 parents 1d65de9 + 238079d commit 96dacfb
Show file tree
Hide file tree
Showing 27 changed files with 340 additions and 324 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
node-version: "20.x"
- run: npm ci
- run: npm run build
- run: npx playwright install --with-deps
- run: npx playwright install chromium webkit --with-deps
- run: npm test
2 changes: 1 addition & 1 deletion docs/src/components/Color.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { color } = Astro.props;
display: inline-flex;
align-items: center;
gap: var(--space-3xs);
border-radius: var(--border-radius);
padding-block: 0;
}
span {
display: inline-block;
Expand Down
169 changes: 169 additions & 0 deletions docs/src/components/IntroExample.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
import Example from "./Example.astro";
---

<Example class="feature">
<div class="card">
<calendar-range months="2">
<svg
aria-label="Previous"
slot="button-previous"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
>
<path d="M15.75 19.5 8.25 12l7.5-7.5"></path>
</svg>
<svg
aria-label="Next"
slot="button-next"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
>
<path d="m8.25 4.5 7.5 7.5-7.5 7.5"></path>
</svg>

<div class="grid">
<calendar-month></calendar-month>
<calendar-month offset="1"></calendar-month>
</div>
</calendar-range>
</div>
</Example>

<script is:inline type="module">
const toISO = (date) => date.toISOString().split("T")[0];

const today = new Date();
const nextWeek = new Date(today);
nextWeek.setDate(nextWeek.getDate() + 7);

document
.querySelector("calendar-range")
?.setAttribute("value", `${toISO(today)}/${toISO(nextWeek)}`);

await Promise.all([
customElements.whenDefined("calendar-range"),
customElements.whenDefined("calendar-month"),
]);

document.querySelector(".card")?.classList.add("reveal");
</script>

<style>
.feature {
--border: #dcdfe5;
--radius: 4px;
--icon-color: #666;
--accent: var(--color-accent);
}

.grid {
display: flex;
gap: 1em;
justify-content: center;
flex-wrap: wrap;
}

.card {
padding: var(--space-s-m);
border-radius: 5px;
border: 1px solid var(--border);
background: white;
box-shadow:
0 1px 5px rgba(0, 0, 0, 0.05),
0 0 30px rgba(0, 0, 0, 0.01);
inline-size: fit-content;
margin-inline: auto;
block-size: fit-content;
transition:
opacity 0.6s ease-in,
transform 0.4s ease-out;

/* avoid reflow */
min-block-size: 643px;
@media (min-height: 594px) {
min-block-size: 402px;
}

/* animate card in when ready */
&:not(.reveal) {
opacity: 0;

@media (prefers-reduced-motion: no-preference) {
transform: translateY(-3em);
}
}
}

calendar-range {
svg {
height: 16px;
width: 16px;
fill: none;
stroke: var(--icon-color);
stroke-width: 1.5;
}

path {
stroke-linecap: round;
stroke-linejoin: round;
}

&::part(button) {
width: 30px;
height: 30px;
border: 1px solid var(--border);
background: white;
color: var(--icon-color);
border-radius: var(--radius);
}

&::part(button):is(:hover, :focus-visible) {
--icon-color: black;
}

&::part(button):hover {
background: rgba(0, 0, 0, 0.02);
}

&::part(button):focus-visible {
outline: 2px solid var(--accent);
outline-offset: -1px;
}
}

calendar-month {
--color-accent: var(--accent);

&::part(button) {
border-radius: var(--radius);
}

&::part(today) {
color: var(--color-accent);
}

&::part(today selected),
&::part(today):focus-visible {
color: white;
}

&::part(range-inner) {
border-radius: 0;
}

&::part(range-start) {
border-start-end-radius: 0;
border-end-end-radius: 0;
}

&::part(range-end) {
border-start-start-radius: 0;
border-end-start-radius: 0;
}

&::part(range-start range-end) {
border-radius: var(--radius);
}
}
</style>
2 changes: 1 addition & 1 deletion docs/src/components/PageIntro.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
font-size: var(--step-2);
color: var(--color-intro);
font-weight: 300;
line-height: 1.4;
line-height: 1.3;
letter-spacing: -0.005em;
text-wrap: pretty;
}
Expand Down
5 changes: 2 additions & 3 deletions docs/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ const { title, root } = Astro.props;
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>
{title} - Cally
</title>
<meta name="theme-color" content="#dc2626" />
<title>{title} - Cally</title>

<slot name="head" />
</head>
Expand Down
13 changes: 2 additions & 11 deletions docs/src/pages/components/calendar-date.astro
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,6 @@ import Link from "../../components/Link.astro";
<td><code>number</code></td>
<td><code>1</code></td>
</tr>
<tr>
<td><code>dir</code></td>
<td><code>dir</code></td>
<td>
The writing direction. Set to <code>"rtl"</code> for RTL languages
</td>
<td><code>"ltr" | "rtl"</code></td>
<td><code>"ltr"</code></td>
</tr>
<tr>
<td><code>isDateDisallowed</code></td>
<td>-</td>
Expand Down Expand Up @@ -169,8 +160,8 @@ import Link from "../../components/Link.astro";
</p>

<p>
See the guide on <Link href="/theming/">theming</Link> for a walkthrough of how
to style this component.
See the guide on <Link href="/guides/theming/">theming</Link> for a walkthrough
of how to style this component.
</p>

<Table>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/calendar-month.astro
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ import Link from "../../components/Link.astro";
</p>

<p>
See the guide on <Link href="/theming/">theming</Link> for a walkthrough of how
to style this component.
See the guide on <Link href="/guides/theming/">theming</Link> for a walkthrough
of how to style this component.
</p>

<Table>
Expand Down
13 changes: 2 additions & 11 deletions docs/src/pages/components/calendar-range.astro
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ import Link from "../../components/Link.astro";
<td><code>number</code></td>
<td><code>1</code></td>
</tr>
<tr>
<td><code>dir</code></td>
<td><code>dir</code></td>
<td>
The writing direction. Set to <code>"rtl"</code> for RTL languages
</td>
<td><code>"ltr" | "rtl"</code></td>
<td><code>"ltr"</code></td>
</tr>
<tr>
<td><code>isDateDisallowed</code></td>
<td>-</td>
Expand Down Expand Up @@ -206,8 +197,8 @@ import Link from "../../components/Link.astro";
</p>

<p>
See the guide on <Link href="/theming/">theming</Link> for a walkthrough of how
to style this component.
See the guide on <Link href="/guides/theming/">theming</Link> for a walkthrough
of how to style this component.
</p>

<Table>
Expand Down
19 changes: 16 additions & 3 deletions docs/src/pages/components/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import Layout from "../../layouts/Layout.astro";
import Link from "../../components/Link.astro";
---

<Layout title="API">
Expand All @@ -11,8 +12,20 @@ import Layout from "../../layouts/Layout.astro";
</p>

<ul>
<li><a href="./calendar-date/"><code>{`<calendar-date>`}</code></a></li>
<li><a href="./calendar-range/"><code>{`<calendar-range>`}</code></a></li>
<li><a href="./calendar-month/"><code>{`<calendar-month>`}</code></a></li>
<li>
<Link href="/components/calendar-date/"
><code>{`<calendar-date>`}</code></Link
>
</li>
<li>
<Link href="/components/calendar-range/"
><code>{`<calendar-range>`}</code></Link
>
</li>
<li>
<Link href="/components/calendar-month/"
><code>{`<calendar-month>`}</code></Link
>
</li>
</ul>
</Layout>
22 changes: 22 additions & 0 deletions docs/src/pages/guides/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
import Layout from "../../layouts/Layout.astro";
import Link from "../../components/Link.astro";
---

<Layout title="Guides">
<h1 slot="intro">Guides</h1>

<p>
Learn how to style Cally's components or integrate with external components
to build more complex UIs.
</p>

<ul>
<li>
<Link href="/guides/theming/">Theming</Link>
</li>
<li>
<Link href="/guides/integration/">Integration</Link>
</li>
</ul>
</Layout>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
import PageIntro from "../components/PageIntro.astro";
import Layout from "../layouts/Layout.astro";
import Example from "../components/Example.astro";
import Note from "../components/Note.astro";
import Heading from "../components/Heading.astro";
import Link from "../components/Link.astro";
import PageIntro from "../../components/PageIntro.astro";
import Layout from "../../layouts/Layout.astro";
import Example from "../../components/Example.astro";
import Note from "../../components/Note.astro";
import Heading from "../../components/Heading.astro";
import Link from "../../components/Link.astro";
---

<Layout title="Integration">
Expand Down Expand Up @@ -122,7 +122,7 @@ import Link from "../components/Link.astro";

<Note>
For more information on styling and theming the calendar components please
see the full <Link href="/theming/">theming</Link> guide.
see the full <Link href="/guides/theming/">theming</Link> guide.
</Note>

<Heading level={2}>The input and toggle button</Heading>
Expand Down Expand Up @@ -426,7 +426,7 @@ import Link from "../components/Link.astro";
<p>
To find out more about each component, please see the respective
<Link href="/components/">component API</Link> docs. Or visit the
<Link href="/theming/">theming</Link> guide for a more in-depth look at styling
the components.
<Link href="/guides/theming/">theming</Link> guide for a more in-depth look at
styling the components.
</p>
</Layout>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
import Layout from "../layouts/Layout.astro";
import Example from "../components/Example.astro";
import Color from "../components/Color.astro";
import Note from "../components/Note.astro";
import PageIntro from "../components/PageIntro.astro";
import Heading from "../components/Heading.astro";
import Link from "../components/Link.astro";
import Layout from "../../layouts/Layout.astro";
import Example from "../../components/Example.astro";
import Color from "../../components/Color.astro";
import Note from "../../components/Note.astro";
import PageIntro from "../../components/PageIntro.astro";
import Heading from "../../components/Heading.astro";
import Link from "../../components/Link.astro";
const colorAccent = "#7048e8";
const colorAccentSecondary = "#845ef7";
Expand Down Expand Up @@ -593,8 +593,8 @@ const colorTextOnAccent = "#ffffff";
<p>
To find out more about each component, please see the respective
<Link href="/components/">component API</Link> docs. Or visit the
<Link href="/theming/">theming</Link> guide for a more in-depth look at styling
the components.
<Link href="/guides/theming/">theming</Link> guide for a more in-depth look at
styling the components.
</p>
</Layout>

Expand Down
Loading

0 comments on commit 96dacfb

Please sign in to comment.