Skip to content

Commit

Permalink
Use latest Remote DOM APIs properly (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonmade authored Sep 16, 2024
1 parent 27b9c10 commit 0dbd36f
Show file tree
Hide file tree
Showing 187 changed files with 4,227 additions and 1,401 deletions.
10 changes: 10 additions & 0 deletions .changeset/few-buttons-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@watching/clips-preact': minor
'@watching/clips-svelte': minor
'@watching/clips-react': minor
'@watching/clips': minor
'@watching/cli': minor
'@watching/thread-render': patch
---

Update custom element APIs
4 changes: 2 additions & 2 deletions .github/workflows/actions/type-check-with-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
path: |
**/build/typescript/
**/*.tsbuildinfo
key: typescript-cache-v2-${{ github.sha }}
restore-keys: typescript-cache-v2-
key: typescript-cache-v3-${{ github.sha }}
restore-keys: typescript-cache-v3-
- run: pnpm run type-check
shell: bash
2 changes: 1 addition & 1 deletion app/features/Account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ function SubscribeSection({
border
cornerRadius
background="subdued"
blockAlignment="spaceBetween"
blockAlignment="space-between"
>
<BlockStack spacing>
<InlineStack spacing="small">
Expand Down
2 changes: 1 addition & 1 deletion app/features/Account/CheckYourEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function CheckYourEmail() {
usePerformanceNavigation();

return (
<View padding="base">
<View padding>
<TextBlock>Check your email!</TextBlock>
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion app/features/Account/CreateAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function CreateAccount() {
);

return (
<BlockStack spacing padding="base">
<BlockStack spacing padding>
<Heading>Create account</Heading>

{reason && <ErrorBanner reason={reason} />}
Expand Down
6 changes: 4 additions & 2 deletions app/features/Authentication/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ function SignInWithEmail() {
label="Email"
value={email}
keyboardType="email"
changeTiming="input"
autocomplete="webauthn username"
onInput={(value) => {
email.value = value;
}}
/>
<Action
disabled={disabled}
Expand Down Expand Up @@ -340,7 +342,7 @@ function CheckYourEmail() {
usePerformanceNavigation({state: 'complete'});

return (
<View padding="base">
<View padding>
<TextBlock>Check your email!</TextBlock>
</View>
);
Expand Down
4 changes: 3 additions & 1 deletion app/features/Developer/Console/Console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ function ConnectToConsole({server}: {server: ClipsLocalDevelopmentServer}) {
<TextField
label="Local server URL"
value={localUrl}
changeTiming="input"
onInput={(value) => {
localUrl.value = value;
}}
/>
<Action disabled={!isValidUrl(localUrl.value)} perform="submit">
Set local URL
Expand Down
16 changes: 7 additions & 9 deletions app/features/Internal/ComponentLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function PopoverComponents() {
<BlockStack spacing>
<Heading>inlineAttachment=center</Heading>

<InlineStack spacing alignment="spaceBetween">
<InlineStack spacing alignment="space-between">
<Spacer size="none" />
<PopoverExample inlineAttachment="center" />
<PopoverExample inlineAttachment="center" />
Expand All @@ -383,7 +383,7 @@ function PopoverComponents() {

<Heading>inlineAttachment=start</Heading>

<InlineStack spacing alignment="spaceBetween">
<InlineStack spacing alignment="space-between">
<PopoverExample inlineAttachment="start" />
<PopoverExample inlineAttachment="start" />
<PopoverExample inlineAttachment="start" />
Expand All @@ -393,7 +393,7 @@ function PopoverComponents() {

<Heading>inlineAttachment=end</Heading>

<InlineStack spacing alignment="spaceBetween">
<InlineStack spacing alignment="space-between">
<PopoverExample inlineAttachment="end" />
<PopoverExample inlineAttachment="end" />
<PopoverExample inlineAttachment="end" />
Expand Down Expand Up @@ -499,10 +499,6 @@ function FormComponents() {
maximumLines={false}
/>
<TextFieldExample label="Controlled text field" />
<TextFieldExample
label="Controlled text field (change on input)"
changeTiming="input"
/>

<Select
label="Select"
Expand Down Expand Up @@ -787,14 +783,16 @@ function SkeletonComponents() {
<TextBlock>Skeleton action</TextBlock>
<InlineStack spacing>
<SkeletonAction />
<SkeletonAction size="medium" />
<SkeletonAction size="small" />
<SkeletonAction size="auto" />
<SkeletonAction size="large" />
<SkeletonAction size={Style.css`2rem`} />
</InlineStack>

<TextBlock>Skeleton text</TextBlock>
<SkeletonText />
<SkeletonText size="medium" />
<SkeletonText size="small" />
<SkeletonText size="auto" />
<SkeletonText size="large" />

<InlineGrid sizes={['fill', 'fill']} spacing>
Expand Down
6 changes: 4 additions & 2 deletions app/features/WatchThrough/WatchThrough.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,9 @@ function NotesTextField({value: notes}: {value: Signal<string | undefined>}) {
minimumLines={4}
maximumLines={10}
value={notes}
changeTiming="input"
onInput={(value) => {
notes.value = value;
}}
/>
);
}
Expand Down Expand Up @@ -726,7 +728,7 @@ function SkipEpisodeModal({

<DetailedReview notes={form.notes} />

<InlineStack alignment="spaceBetween" spacing="small">
<InlineStack alignment="space-between" spacing="small">
<EpisodeDatePicker action="skip" value={form.at} />
<Action emphasis perform="submit">
Skip Episode
Expand Down
7 changes: 4 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@
"@quilted/graphql-tools": "^0.2.11",
"@quilted/localize": "^0.2.1",
"@quilted/quilt": "^0.8.1",
"@remote-dom/core": "^1.4.0",
"@remote-dom/preact": "^1.1.0",
"@remote-dom/react": "^1.1.0",
"@remote-dom/core": "^1.5.0",
"@remote-dom/preact": "^1.2.0",
"@remote-dom/react": "^1.2.0",
"@simplewebauthn/browser": "^6.2.0",
"@simplewebauthn/server": "^6.2.0",
"@stripe/stripe-js": "^1.46.0",
"@types/common-tags": "^1.8.0",
"@types/jsonwebtoken": "^8.0.0",
"@watching/api": "workspace:*",
"@watching/clips": "workspace:*",
"@watching/design": "workspace:*",
"@watching/thread-render": "workspace:*",
"@watching/tools": "workspace:*",
"base64url": "^3.0.1",
Expand Down
30 changes: 23 additions & 7 deletions app/shared/clips/components/Action.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import {Action as UiAction} from '@lemon/zest';
import {usePossibleThreadSignals, createClipsComponent} from './shared.ts';
import {Action as UIAction} from '@lemon/zest';
import {
createClipsComponentRenderer,
useRenderedChildren,
wrapEventListenerForCallback,
} from './shared.ts';

export const Action = createClipsComponent(
export const Action = createClipsComponentRenderer(
'ui-action',
function Action({to, disabled, onPress, overlay, children}) {
const signalProps = usePossibleThreadSignals({disabled});
function Action(props) {
const {overlay, children} = useRenderedChildren(props, {
slotProps: ['overlay'],
});

const attributes = props.element.attributes.value;
const events = props.element.eventListeners.value;

return (
<UiAction {...signalProps} to={to} onPress={onPress} overlay={overlay}>
<UIAction
to={attributes.to}
disabled={attributes.disabled != null}
onPress={
events.press ? wrapEventListenerForCallback(events.press) : undefined
}
overlay={overlay}
>
{children}
</UiAction>
</UIAction>
);
},
);
78 changes: 46 additions & 32 deletions app/shared/clips/components/BlockGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,54 @@
import {BlockGrid as UiBlockGrid} from '@lemon/zest';
import {createClipsComponent} from './shared.ts';
import {
SPACING_KEYWORDS,
ALIGNMENT_KEYWORDS,
LAYOUT_MODE_KEYWORDS,
} from '@watching/design';
import {BlockGrid as UIBlockGrid} from '@lemon/zest';

export const BlockGrid = createClipsComponent(
import {useViewProps} from './View.tsx';
import {parseGridSizesAttribute} from './Grid.tsx';

import {
createClipsComponentRenderer,
restrictToAllowedValues,
useRenderedChildren,
} from './shared.ts';

export const BlockGrid = createClipsComponentRenderer(
'ui-block-grid',
function BlockGrid({
children,
sizes,
spacing,
blockSpacing,
inlineSpacing,
blockAlignment,
inlineAlignment,
layoutMode,
padding,
paddingBlockEnd,
paddingBlockStart,
paddingInlineEnd,
paddingInlineStart,
}) {
function BlockGrid(props) {
const {children} = useRenderedChildren(props);

const attributes = props.element.attributes.value;

return (
<UiBlockGrid
sizes={sizes}
spacing={spacing}
blockSpacing={blockSpacing}
inlineSpacing={inlineSpacing}
blockAlignment={blockAlignment}
inlineAlignment={inlineAlignment}
layoutMode={layoutMode}
padding={padding}
paddingBlockEnd={paddingBlockEnd}
paddingBlockStart={paddingBlockStart}
paddingInlineEnd={paddingInlineEnd}
paddingInlineStart={paddingInlineStart}
<UIBlockGrid
{...useViewProps(props)}
sizes={parseGridSizesAttribute(attributes.sizes)}
spacing={restrictToAllowedValues(attributes.spacing, SPACING_KEYWORDS)}
blockSpacing={restrictToAllowedValues(
attributes.blockSpacing,
SPACING_KEYWORDS,
)}
inlineSpacing={restrictToAllowedValues(
attributes.inlineSpacing,
SPACING_KEYWORDS,
)}
blockAlignment={restrictToAllowedValues(
attributes.blockAlignment,
ALIGNMENT_KEYWORDS,
)}
inlineAlignment={restrictToAllowedValues(
attributes.inlineAlignment,
ALIGNMENT_KEYWORDS,
)}
layoutMode={restrictToAllowedValues(
attributes.layoutMode,
LAYOUT_MODE_KEYWORDS,
)}
>
{children}
</UiBlockGrid>
</UIBlockGrid>
);
},
);
62 changes: 36 additions & 26 deletions app/shared/clips/components/BlockStack.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
import {BlockStack as UiBlockStack} from '@lemon/zest';
import {createClipsComponent} from './shared.ts';
import {
SPACING_KEYWORDS,
ALIGNMENT_KEYWORDS,
LAYOUT_MODE_KEYWORDS,
} from '@watching/design';
import {BlockStack as UIBlockStack} from '@lemon/zest';

export const BlockStack = createClipsComponent(
import {useViewProps} from './View.tsx';

import {
createClipsComponentRenderer,
restrictToAllowedValues,
useRenderedChildren,
} from './shared.ts';

export const BlockStack = createClipsComponentRenderer(
'ui-block-stack',
function BlockStack({
children,
spacing,
blockAlignment,
inlineAlignment,
layoutMode,
padding,
paddingBlockEnd,
paddingBlockStart,
paddingInlineEnd,
paddingInlineStart,
}) {
function BlockStack(props) {
const {children} = useRenderedChildren(props);

const attributes = props.element.attributes.value;

return (
<UiBlockStack
spacing={spacing}
blockAlignment={blockAlignment}
inlineAlignment={inlineAlignment}
layoutMode={layoutMode}
padding={padding}
paddingBlockEnd={paddingBlockEnd}
paddingBlockStart={paddingBlockStart}
paddingInlineEnd={paddingInlineEnd}
paddingInlineStart={paddingInlineStart}
<UIBlockStack
{...useViewProps(props)}
spacing={restrictToAllowedValues(attributes.spacing, SPACING_KEYWORDS)}
inlineAlignment={restrictToAllowedValues(
attributes.inlineAlignment,
ALIGNMENT_KEYWORDS,
)}
blockAlignment={restrictToAllowedValues(
attributes.blockAlignment,
ALIGNMENT_KEYWORDS,
)}
layoutMode={restrictToAllowedValues(
attributes.layoutMode,
LAYOUT_MODE_KEYWORDS,
)}
>
{children}
</UiBlockStack>
</UIBlockStack>
);
},
);
19 changes: 14 additions & 5 deletions app/shared/clips/components/Disclosure.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import {Disclosure as UiDisclosure} from '@lemon/zest';
import {createClipsComponent} from './shared.ts';
import {Disclosure as UIDisclosure} from '@lemon/zest';

export const Disclosure = createClipsComponent(
import {createClipsComponentRenderer, useRenderedChildren} from './shared.ts';

export const Disclosure = createClipsComponentRenderer(
'ui-disclosure',
function Disclosure({children, label}) {
return <UiDisclosure label={label}>{children}</UiDisclosure>;
function Disclosure(props) {
const {label, children} = useRenderedChildren(props, {
slotProps: ['label'],
});

const attributes = props.element.attributes.value;

return (
<UIDisclosure label={label ?? attributes.label}>{children}</UIDisclosure>
);
},
);
Loading

0 comments on commit 0dbd36f

Please sign in to comment.