-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add server-only components for RSCs
- Loading branch information
Dominique Wirz
committed
Feb 7, 2024
1 parent
c3d7ec7
commit b496764
Showing
34 changed files
with
5,476 additions
and
8,207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ out | |
|
||
# production | ||
build | ||
hydrate | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FC, ReactNode } from 'react'; | ||
|
||
export const Section: FC<{ title: string; variants: { title: string; children: ReactNode }[] }> = ({ title, variants }) => ( | ||
<section style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}> | ||
<h2>{title}</h2> | ||
<div | ||
style={{ | ||
display: 'grid', | ||
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))', | ||
gap: '2rem', | ||
}} | ||
> | ||
{variants.map(({ title, children }) => ( | ||
<div key={title}> | ||
<h3>{title}</h3> | ||
{children} | ||
</div> | ||
))} | ||
</div> | ||
<hr style={{ width: '100%' }} /> | ||
</section> | ||
); |
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
packages/app/src/components/accordion/accordion-client-only.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use client'; | ||
|
||
import { AbcAccordion, AbcAccordionGroup } from 'abc-web-components-react-wrapper'; | ||
import { FC } from 'react'; | ||
import { data } from './data'; | ||
|
||
export const AccordionClientOnly: FC = () => ( | ||
<AbcAccordionGroup onAccordionChange={(event) => console.info(event.detail)}> | ||
{data.map(({ item, summary, details }) => ( | ||
<AbcAccordion | ||
key={item} | ||
slot="accordions" | ||
item={item} | ||
summary={summary} | ||
variant="white" | ||
onAccordionClick={({ detail }) => console.info(detail)} | ||
> | ||
<span slot="details">{details}</span> | ||
</AbcAccordion> | ||
))} | ||
</AbcAccordionGroup> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AbcAccordionGroupServerOnly, staticAbcAccordionHtmlServerOnly } from 'abc-web-components-react-wrapper'; | ||
import { FC } from 'react'; | ||
import { AccordionWithRSC } from './accordion-with-rsc'; | ||
import { data } from './data'; | ||
|
||
export const AccordionRSC: FC = async () => { | ||
const accordions = await Promise.all( | ||
data.map(({ item, summary }) => | ||
staticAbcAccordionHtmlServerOnly({ slot: 'accordions', item, summary, variant: 'white' }), | ||
), | ||
); | ||
|
||
return <AccordionWithRSC rsc={<AbcAccordionGroupServerOnly>{accordions.join('')}</AbcAccordionGroupServerOnly>} />; | ||
}; |
11 changes: 11 additions & 0 deletions
11
packages/app/src/components/accordion/accordion-with-rsc.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client'; | ||
|
||
import { WithRSCFallback } from 'abc-web-components-react-wrapper/client'; | ||
import { ComponentProps, FC } from 'react'; | ||
import { AccordionClientOnly } from './accordion-client-only'; | ||
|
||
export const AccordionWithRSC: FC<ComponentProps<typeof WithRSCFallback>> = ({ rsc }) => ( | ||
<WithRSCFallback rsc={rsc}> | ||
<AccordionClientOnly /> | ||
</WithRSCFallback> | ||
); |
11 changes: 11 additions & 0 deletions
11
packages/app/src/components/accordion/accordion-with-wrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client'; | ||
|
||
import { AbcWrapper } from 'abc-web-components-react-wrapper/client'; | ||
import { FC } from 'react'; | ||
import { AccordionClientOnly } from './accordion-client-only'; | ||
|
||
export const AccordionWithWrapper: FC = () => ( | ||
<AbcWrapper> | ||
<AccordionClientOnly /> | ||
</AbcWrapper> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const data = [ | ||
{ | ||
item: 'first', | ||
summary: 'Placeholder 1', | ||
details: | ||
'Sint officia sunt nulla deserunt. Eu tempor veniam Lorem laboris reprehenderit culpa esse anim aliquip minim. Est do minim ipsum fugiat incididunt.', | ||
}, | ||
{ | ||
item: 'second', | ||
summary: 'Placeholder 2', | ||
details: | ||
'Commodo ipsum ut qui nostrud mollit ex esse duis consequat pariatur commodo do. Consequat consequat ad ut sit dolor exercitation magna ex pariatur Lorem consequat elit duis. Irure minim eiusmod irure do elit. Officia culpa eiusmod do est sunt exercitation esse id fugiat ut.', | ||
}, | ||
{ | ||
item: 'third', | ||
summary: 'Placeholder 3', | ||
details: | ||
'Deserunt commodo consectetur nostrud minim sint amet. Voluptate incididunt mollit aliqua id ipsum. Quis pariatur commodo et qui officia sit eiusmod minim elit commodo excepteur commodo. Nisi deserunt nisi aute elit nulla est proident non cillum reprehenderit pariatur ad. Elit ad qui magna nulla esse.', | ||
}, | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use client'; | ||
|
||
import { AbcButton } from 'abc-web-components-react-wrapper'; | ||
import { FC, PropsWithChildren } from 'react'; | ||
|
||
export const ButtonClientOnly: FC<PropsWithChildren> = ({ children }) => ( | ||
<AbcButton variant="primary" size="md" as="button" onClick={(event) => console.info(event)}> | ||
{children} | ||
</AbcButton> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AbcButtonServerOnly } from 'abc-web-components-react-wrapper'; | ||
import { FC, PropsWithChildren } from 'react'; | ||
import { ButtonWithRSC } from './button-with-rsc'; | ||
|
||
export const ButtonRSC: FC<PropsWithChildren> = ({ children }) => ( | ||
<ButtonWithRSC rsc={<AbcButtonServerOnly>{children}</AbcButtonServerOnly>}>{children}</ButtonWithRSC> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use client'; | ||
|
||
import { AbcButton } from 'abc-web-components-react-wrapper'; | ||
import { WithRSCFallback } from 'abc-web-components-react-wrapper/client'; | ||
import { ComponentProps, FC, PropsWithChildren } from 'react'; | ||
|
||
type Props = PropsWithChildren<ComponentProps<typeof WithRSCFallback>>; | ||
|
||
export const ButtonWithRSC: FC<Props> = ({ rsc, children }) => ( | ||
<WithRSCFallback rsc={rsc}> | ||
<AbcButton onClick={(event) => console.info(event)}>{children}</AbcButton> | ||
</WithRSCFallback> | ||
); |
11 changes: 11 additions & 0 deletions
11
packages/app/src/components/button/button-with-wrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client'; | ||
|
||
import { AbcWrapper } from 'abc-web-components-react-wrapper/client'; | ||
import { FC, PropsWithChildren } from 'react'; | ||
import { ButtonClientOnly } from './button-client-only'; | ||
|
||
export const ButtonWithWrapper: FC<PropsWithChildren> = ({ children }) => ( | ||
<AbcWrapper> | ||
<ButtonClientOnly>{children}</ButtonClientOnly> | ||
</AbcWrapper> | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const data = [ | ||
{ item: 'first', label: 'Placeholder 1' }, | ||
{ item: 'second', label: 'Placeholder 2' }, | ||
{ item: 'third', label: 'Placeholder 3' }, | ||
]; |
17 changes: 17 additions & 0 deletions
17
packages/app/src/components/dropdown/dropdown-client-only.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client'; | ||
|
||
import { AbcDropdown, AbcFlyout, AbcFlyoutItem } from 'abc-web-components-react-wrapper'; | ||
import { ComponentProps, FC } from 'react'; | ||
import { data } from './data'; | ||
|
||
type Props = ComponentProps<typeof AbcDropdown>; | ||
|
||
export const DropdownClientOnly: FC<Props> = ({ text, hint, label }) => ( | ||
<AbcDropdown text={text} hint={hint} label={label} onDropdownChange={(event) => console.info(event.detail)}> | ||
<AbcFlyout> | ||
{data.map(({ item, label }) => ( | ||
<AbcFlyoutItem key={item} item={item} label={label} /> | ||
))} | ||
</AbcFlyout> | ||
</AbcDropdown> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AbcDropdownServerOnly } from 'abc-web-components-react-wrapper'; | ||
import { ComponentProps, FC } from 'react'; | ||
import { DropdownWithRSC } from './dropdown-with-rsc'; | ||
|
||
type Props = ComponentProps<typeof AbcDropdownServerOnly>; | ||
|
||
export const DropdownRSC: FC<Props> = async ({ text, hint, label }) => ( | ||
<DropdownWithRSC | ||
rsc={<AbcDropdownServerOnly text={text} hint={hint} label={label} />} | ||
text={text} | ||
hint={hint} | ||
label={label} | ||
/> | ||
); |
14 changes: 14 additions & 0 deletions
14
packages/app/src/components/dropdown/dropdown-with-rsc.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use client'; | ||
|
||
import { AbcDropdownServerOnly } from 'abc-web-components-react-wrapper'; | ||
import { WithRSCFallback } from 'abc-web-components-react-wrapper/client'; | ||
import { ComponentProps, FC } from 'react'; | ||
import { DropdownClientOnly } from './dropdown-client-only'; | ||
|
||
type Props = ComponentProps<typeof WithRSCFallback> & ComponentProps<typeof AbcDropdownServerOnly>; | ||
|
||
export const DropdownWithRSC: FC<Props> = ({ rsc, text, hint, label }) => ( | ||
<WithRSCFallback rsc={rsc}> | ||
<DropdownClientOnly text={text} hint={hint} label={label} /> | ||
</WithRSCFallback> | ||
); |
14 changes: 14 additions & 0 deletions
14
packages/app/src/components/dropdown/dropdown-with-wrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use client'; | ||
|
||
import { AbcWrapper } from 'abc-web-components-react-wrapper/client'; | ||
import { ComponentProps, FC } from 'react'; | ||
import { DropdownClientOnly } from './dropdown-client-only'; | ||
import { AbcDropdownServerOnly } from 'abc-web-components-react-wrapper'; | ||
|
||
type Props = ComponentProps<typeof AbcDropdownServerOnly>; | ||
|
||
export const DropdownWithWrapper: FC<Props> = ({ text, hint, label }) => ( | ||
<AbcWrapper> | ||
<DropdownClientOnly text={text} hint={hint} label={label} /> | ||
</AbcWrapper> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist/ | ||
node_modules/ | ||
*.tgz | ||
.npmrc |
Oops, something went wrong.