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

feat(suspensive.org): add Sandpack component #963

Merged
merged 3 commits into from
Jun 24, 2024
Merged

feat(suspensive.org): add Sandpack component #963

merged 3 commits into from
Jun 24, 2024

Conversation

kangju2000
Copy link
Collaborator

Overview

related #867
closed #7

I have set up the documentation to easily add examples in MDX using Sandpack from CodeSandbox.

I have also carried over the theme selected in the related PR. If there's anything else that needs to be configured, please let me know!

Usage

import { Sandpack } from '@/components'

<Sandpack  
  customSetup={{
    dependencies: {
      '@suspensive/react': 'latest',
      '@suspensive/react-query': 'latest',
      '@tanstack/react-query': '^4.0.0',
    },
  }}
>

```js /App.tsx
import Example from './Example'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient()

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <Example />
    </QueryClientProvider>
  )
}
```

```js /Example.tsx active
import { wrap } from '@suspensive/react'
import { useSuspenseQuery } from '@suspensive/react-query'
import { api } from './api'

export default wrap
  .ErrorBoundaryGroup({ blockOutside: false })
  .ErrorBoundary({ fallback: ({ error }) => <>{error.message}</> })
  .Suspense({ fallback: <>loading...</>, clientOnly: true })
  .on(() => {
    const query = useSuspenseQuery({
      queryKey: ['key'],
      queryFn: () => api.text(),
    })
    return <>{query.data.text}</>
  })
```

```js /api.ts
export const api = {
  text: async () => {
    await new Promise((resolve) => setTimeout(resolve, 1000))
    return { text: 'Hello, Suspensive!' }
  },
}
```

</Sandpack>

Result

2024-06-24.1.32.43.mov

PR Checklist

  • I did below actions if need
  1. I read the Contributing Guide
  2. I added documents and tests.

Copy link

vercel bot commented Jun 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 5:35am
v1.suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 5:35am
visualization.suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 5:35am

Copy link

changeset-bot bot commented Jun 24, 2024

🦋 Changeset detected

Latest commit: 9863328

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codspeed-hq bot commented Jun 24, 2024

CodSpeed Performance Report

Merging #963 will create unknown performance changes

Comparing sandpack (9863328) with main (20119f8)

Summary

⚠️ No benchmarks were detected in both the base of the PR and the PR.

@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.67%. Comparing base (20119f8) to head (9863328).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #963   +/-   ##
=======================================
  Coverage   80.67%   80.67%           
=======================================
  Files          36       36           
  Lines         445      445           
  Branches       98       98           
=======================================
  Hits          359      359           
  Misses         77       77           
  Partials        9        9           
Components Coverage Δ
@suspensive/react 96.98% <ø> (ø)
@suspensive/react-query ∅ <ø> (∅)
@suspensive/react-query-4 0.00% <ø> (ø)
@suspensive/react-query-5 0.00% <ø> (ø)
@suspensive/react-await 100.00% <ø> (ø)
@suspensive/react-image 23.52% <ø> (ø)

import { atomDark } from '@codesandbox/sandpack-themes'
import type { ComponentProps } from 'react'

export const Sandpack = (props: Omit<ComponentProps<typeof SandpackReact>, 'template'>) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool! ❄️

@kangju2000 kangju2000 changed the title feat: add Sandpack component feat(suspensive.org): add Sandpack component Jun 24, 2024
Copy link
Member

@minsoo-web minsoo-web left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool 🚀
Many thanks!!

@manudeli manudeli merged commit 8eb8892 into main Jun 24, 2024
16 checks passed
@manudeli manudeli deleted the sandpack branch June 24, 2024 06:33
@kangju2000 kangju2000 mentioned this pull request Jun 24, 2024
1 task
manudeli pushed a commit that referenced this pull request Jun 24, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->
related #963

To resolve the changeset CI error, remove the changeset from the
previous PR.



## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
@kangju2000 kangju2000 mentioned this pull request Jun 25, 2024
1 task
manudeli pushed a commit that referenced this pull request Jun 25, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

In this [PR](#963), the
TypeScript version in the lockfile was changed to my local version
"5.5.2", so I reverted it. 😅

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview
<!--
    A clear and concise description of what this pr is about.
 -->
related #867
closed #7

I have set up the documentation to easily add examples in MDX using
Sandpack from CodeSandbox.

I have also carried over the theme selected in the [related
PR](#867). If there's anything
else that needs to be configured, please let me know!

## Usage

````mdx
import { Sandpack } from '@/components'

<Sandpack  
  customSetup={{
    dependencies: {
      '@suspensive/react': 'latest',
      '@suspensive/react-query': 'latest',
      '@tanstack/react-query': '^4.0.0',
    },
  }}
>

```js /App.tsx
import Example from './Example'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient()

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <Example />
    </QueryClientProvider>
  )
}
```

```js /Example.tsx active
import { wrap } from '@suspensive/react'
import { useSuspenseQuery } from '@suspensive/react-query'
import { api } from './api'

export default wrap
  .ErrorBoundaryGroup({ blockOutside: false })
  .ErrorBoundary({ fallback: ({ error }) => <>{error.message}</> })
  .Suspense({ fallback: <>loading...</>, clientOnly: true })
  .on(() => {
    const query = useSuspenseQuery({
      queryKey: ['key'],
      queryFn: () => api.text(),
    })
    return <>{query.data.text}</>
  })
```

```js /api.ts
export const api = {
  text: async () => {
    await new Promise((resolve) => setTimeout(resolve, 1000))
    return { text: 'Hello, Suspensive!' }
  },
}
```

</Sandpack>

````


### Result


https://github.com/toss/suspensive/assets/23312485/370b6508-cd9b-494d-8ea6-28273eaabba8


## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->
related #963

To resolve the changeset CI error, remove the changeset from the
previous PR.



## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

In this [PR](#963), the
TypeScript version in the lockfile was changed to my local version
"5.5.2", so I reverted it. 😅

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview
<!--
    A clear and concise description of what this pr is about.
 -->
related #867
closed #7

I have set up the documentation to easily add examples in MDX using
Sandpack from CodeSandbox.

I have also carried over the theme selected in the [related
PR](#867). If there's anything
else that needs to be configured, please let me know!

## Usage

````mdx
import { Sandpack } from '@/components'

<Sandpack  
  customSetup={{
    dependencies: {
      '@suspensive/react': 'latest',
      '@suspensive/react-query': 'latest',
      '@tanstack/react-query': '^4.0.0',
    },
  }}
>

```js /App.tsx
import Example from './Example'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient()

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <Example />
    </QueryClientProvider>
  )
}
```

```js /Example.tsx active
import { wrap } from '@suspensive/react'
import { useSuspenseQuery } from '@suspensive/react-query'
import { api } from './api'

export default wrap
  .ErrorBoundaryGroup({ blockOutside: false })
  .ErrorBoundary({ fallback: ({ error }) => <>{error.message}</> })
  .Suspense({ fallback: <>loading...</>, clientOnly: true })
  .on(() => {
    const query = useSuspenseQuery({
      queryKey: ['key'],
      queryFn: () => api.text(),
    })
    return <>{query.data.text}</>
  })
```

```js /api.ts
export const api = {
  text: async () => {
    await new Promise((resolve) => setTimeout(resolve, 1000))
    return { text: 'Hello, Suspensive!' }
  },
}
```

</Sandpack>

````


### Result


https://github.com/toss/suspensive/assets/23312485/370b6508-cd9b-494d-8ea6-28273eaabba8


## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->
related #963

To resolve the changeset CI error, remove the changeset from the
previous PR.



## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

In this [PR](#963), the
TypeScript version in the lockfile was changed to my local version
"5.5.2", so I reverted it. 😅

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview
<!--
    A clear and concise description of what this pr is about.
 -->
related #867
closed #7

I have set up the documentation to easily add examples in MDX using
Sandpack from CodeSandbox.

I have also carried over the theme selected in the [related
PR](#867). If there's anything
else that needs to be configured, please let me know!

## Usage

````mdx
import { Sandpack } from '@/components'

<Sandpack  
  customSetup={{
    dependencies: {
      '@suspensive/react': 'latest',
      '@suspensive/react-query': 'latest',
      '@tanstack/react-query': '^4.0.0',
    },
  }}
>

```js /App.tsx
import Example from './Example'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient()

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <Example />
    </QueryClientProvider>
  )
}
```

```js /Example.tsx active
import { wrap } from '@suspensive/react'
import { useSuspenseQuery } from '@suspensive/react-query'
import { api } from './api'

export default wrap
  .ErrorBoundaryGroup({ blockOutside: false })
  .ErrorBoundary({ fallback: ({ error }) => <>{error.message}</> })
  .Suspense({ fallback: <>loading...</>, clientOnly: true })
  .on(() => {
    const query = useSuspenseQuery({
      queryKey: ['key'],
      queryFn: () => api.text(),
    })
    return <>{query.data.text}</>
  })
```

```js /api.ts
export const api = {
  text: async () => {
    await new Promise((resolve) => setTimeout(resolve, 1000))
    return { text: 'Hello, Suspensive!' }
  },
}
```

</Sandpack>

````


### Result


https://github.com/toss/suspensive/assets/23312485/370b6508-cd9b-494d-8ea6-28273eaabba8


## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->
related #963

To resolve the changeset CI error, remove the changeset from the
previous PR.



## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

In this [PR](#963), the
TypeScript version in the lockfile was changed to my local version
"5.5.2", so I reverted it. 😅

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview
<!--
    A clear and concise description of what this pr is about.
 -->
related #867
closed #7

I have set up the documentation to easily add examples in MDX using
Sandpack from CodeSandbox.

I have also carried over the theme selected in the [related
PR](#867). If there's anything
else that needs to be configured, please let me know!

## Usage

````mdx
import { Sandpack } from '@/components'

<Sandpack  
  customSetup={{
    dependencies: {
      '@suspensive/react': 'latest',
      '@suspensive/react-query': 'latest',
      '@tanstack/react-query': '^4.0.0',
    },
  }}
>

```js /App.tsx
import Example from './Example'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient()

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <Example />
    </QueryClientProvider>
  )
}
```

```js /Example.tsx active
import { wrap } from '@suspensive/react'
import { useSuspenseQuery } from '@suspensive/react-query'
import { api } from './api'

export default wrap
  .ErrorBoundaryGroup({ blockOutside: false })
  .ErrorBoundary({ fallback: ({ error }) => <>{error.message}</> })
  .Suspense({ fallback: <>loading...</>, clientOnly: true })
  .on(() => {
    const query = useSuspenseQuery({
      queryKey: ['key'],
      queryFn: () => api.text(),
    })
    return <>{query.data.text}</>
  })
```

```js /api.ts
export const api = {
  text: async () => {
    await new Promise((resolve) => setTimeout(resolve, 1000))
    return { text: 'Hello, Suspensive!' }
  },
}
```

</Sandpack>

````


### Result


https://github.com/toss/suspensive/assets/23312485/370b6508-cd9b-494d-8ea6-28273eaabba8


## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->
related #963

To resolve the changeset CI error, remove the changeset from the
previous PR.



## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
manudeli pushed a commit that referenced this pull request Aug 3, 2024
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

In this [PR](#963), the
TypeScript version in the lockfile was changed to my local version
"5.5.2", so I reverted it. 😅

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Support codesandbox to provide interactive examples
4 participants