Skip to content

Commit

Permalink
Merge branch 'master' into fix/asyncify-replace-placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
PuruVJ committed Sep 8, 2023
2 parents 0961895 + d99a85c commit 1cb8f3e
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-weeks-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/site-kit': minor
---

fix: export open_nav function, storify some variables
2 changes: 2 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"itchy-bikes-allow",
"itchy-carrots-bathe",
"khaki-islands-bathe",
"long-weeks-turn",
"lovely-tools-march",
"nasty-keys-grow",
"new-cherries-drop",
Expand All @@ -42,6 +43,7 @@
"spicy-months-breathe",
"spicy-shoes-explain",
"strange-clocks-join",
"strange-students-beam",
"swift-rings-thank",
"swift-turkeys-invent",
"tame-toys-accept",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/strange-students-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/site-kit': patch
---

Wrap blockquote content on end of word, not every character
12 changes: 12 additions & 0 deletions packages/site-kit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @sveltejs/site-kit changelog

## 6.0.0-next.39

### Minor Changes

- 358dd2d: fix: export open_nav function, storify some variables

## 6.0.0-next.38

### Patch Changes

- 8e9e663: Wrap blockquote content on end of word, not every character

## 6.0.0-next.37

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/site-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/site-kit",
"version": "6.0.0-next.37",
"version": "6.0.0-next.39",
"description": "Styles and components for use in *.svelte.dev websites",
"type": "module",
"scripts": {
Expand Down
82 changes: 47 additions & 35 deletions packages/site-kit/src/lib/nav/Menu.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
<script context="module">
const open_store = writable(false);
/** @type {import('svelte/store').Writable<import('../types').NavigationLink | undefined>} */
const current_menu_view = writable(undefined);
const show_context_menu = writable(false);
/** @type {import('svelte/store').Writable<import('../types').NavigationLink[]>} */
const links_store = writable([]);
export function open_nav() {
if (get(open_store)) {
open_store.set(false);
} else {
open_store.set(true);
const segment = get(page).url.pathname.split('/')[1];
current_menu_view.set(get(links_store).find((link) => link.prefix === segment));
show_context_menu.set(!!get(current_menu_view)?.sections && !!get(current_menu_view));
}
}
</script>
<script>
import { afterNavigate } from '$app/navigation';
import { page } from '$app/stores';
import { click_outside, focus_outside, trap } from '$lib/actions';
import { overlay_open, reduced_motion, theme } from '$lib/stores';
import { tick } from 'svelte';
import { expoOut, quintOut } from 'svelte/easing';
import { get, writable } from 'svelte/store';
import Icon from '../components/Icon.svelte';
import NavContextMenu from './NavContextMenu.svelte';
Expand All @@ -14,28 +40,25 @@
/** @type {import('../types').NavigationLink[]} */
export let links;
/** @type {import('../types').NavigationLink | undefined} */
let current_menu_view = undefined;
$: $open_store = open;
$: $links_store = links;
/** @type {NavContextMenu} */
let nav_context_instance;
let menu_height = 0;
let universal_menu_inner_height = 0;
let ready = false;
let show_context_menu = false;
/** @type {HTMLElement} */
let universal_menu;
/** @type {HTMLElement} */
let context_menu;
/** @type {HTMLButtonElement} */
let menu_button;
function close() {
open = false;
$open_store = open;
}
afterNavigate(close);
Expand Down Expand Up @@ -64,7 +87,7 @@
* @returns {import('svelte/transition').TransitionConfig}
*/
const slide = (node, { duration = 400, easing = expoOut } = {}) => {
const height = current_menu_view ? node.clientHeight : universal_menu_inner_height;
const height = $current_menu_view ? node.clientHeight : universal_menu_inner_height;
return {
css: (t, u) =>
Expand All @@ -78,7 +101,7 @@
};
};
$: $overlay_open = open;
$: $overlay_open = $open_store;
</script>
<svelte:window
Expand All @@ -95,35 +118,24 @@
<div style="display: contents" use:click_outside={close} use:focus_outside={close}>
<button
aria-label="Toggle menu"
aria-expanded={open}
aria-expanded={$open_store}
class="menu-toggle"
class:open
bind:this={menu_button}
on:click={() => {
if (open) {
close();
} else {
open = true;

const segment = $page.url.pathname.split('/')[1];
current_menu_view = links.find((link) => link.prefix === segment);

show_context_menu = !!current_menu_view?.sections && !!current_menu_view;
}
}}
on:click={open_nav}
>
<Icon name={open ? 'close' : 'menu'} size="1em" />
<Icon name={$open_store ? 'close' : 'menu'} size="1em" />
</button>
{#if open}
{#if $open_store}
<div class="menu" use:trap={{ reset_focus: false }}>
<div class="mobile-main-menu" in:slide out:slide={{ duration: 500, easing: quintOut }}>
<div
class="menu-background"
class:dark={$theme.current === 'dark'}
class:ready
style:height={show_context_menu ? '99%' : `${universal_menu_inner_height}px`}
style:--background={show_context_menu ? 'var(--sk-back-3)' : null}
style:height={$show_context_menu ? '99%' : `${universal_menu_inner_height}px`}
style:--background={$show_context_menu ? 'var(--sk-back-3)' : null}
use:mounted={(mounted) => (ready = mounted)}
/>
Expand All @@ -142,8 +154,8 @@
const a = 'calc(var(--height-difference) + 1px)';
const b = '1px';
const start = show_context_menu ? a : b;
const end = show_context_menu ? b : a;
const start = $show_context_menu ? a : b;
const end = $show_context_menu ? b : a;
const container = e.currentTarget;
Expand All @@ -162,18 +174,18 @@
e.currentTarget.style.clipPath = '';
// whenever we transition from one menu to the other, we need to move focus to the first item in the new menu
if (!show_context_menu) {
if (!$show_context_menu) {
universal_menu.querySelector('a')?.focus();
}
}}
>
<div
class="viewport"
class:reduced-motion={$reduced_motion}
class:offset={show_context_menu}
class:offset={$show_context_menu}
bind:clientHeight={menu_height}
>
<div class="universal" inert={show_context_menu} bind:this={universal_menu}>
<div class="universal" inert={$show_context_menu} bind:this={universal_menu}>
<div class="contents" bind:clientHeight={universal_menu_inner_height}>
{#each links as link}
<div class="link-item" style:--button-width={link.sections ? '4rem' : '0'}>
Expand All @@ -185,11 +197,11 @@
<button
class="related-menu-arrow"
on:click|preventDefault={async () => {
current_menu_view = link;
$current_menu_view = link;
await tick();
show_context_menu = true;
$show_context_menu = true;
await tick();
Expand All @@ -207,19 +219,19 @@
</div>
</div>
<div class="context" inert={!show_context_menu} bind:this={context_menu}>
<div class="context" inert={!$show_context_menu}>
{#if current_menu_view}
<NavContextMenu
bind:this={nav_context_instance}
contents={current_menu_view.sections}
contents={$current_menu_view?.sections}
/>
{/if}
</div>
<button
class="back-button"
class:dark={$theme.current === 'dark'}
on:click={() => (show_context_menu = false)}
on:click={() => ($show_context_menu = false)}
inert={!show_context_menu}
>
<Icon name="arrow-left" size=".6em" />
Expand Down
1 change: 1 addition & 0 deletions packages/site-kit/src/lib/nav/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { open_nav } from './Menu.svelte';
export { default as Nav } from './Nav.svelte';
export { default as PreloadingIndicator } from './PreloadingIndicator.svelte';
export { default as Separator } from './Separator.svelte';
Expand Down
2 changes: 1 addition & 1 deletion packages/site-kit/src/lib/styles/text.css
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
}

.text :where(blockquote *) {
word-break: break-all;
word-break: break-word;
}
}

Expand Down

0 comments on commit 1cb8f3e

Please sign in to comment.