Skip to content

docs: add /apply-theme route with customizing theme feature #4292

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

Closed
wants to merge 9 commits into from

Conversation

tomchentw
Copy link
Contributor

📝 Description

This PR adds the /apply-theme route to the official v1 docs site. It allows user to try customizing theme directly on the v1 docs site.

🚀 New behavior

This is fairly useful for the users to experiment with Chakra-UI. It also provides a way for organization users to create a public Gist that hosts their design system, saving their needs to create a forked Chakra-UI documentation site.

JPEG-1

To get started, the user has two different ways to interact with this route:

  1. Import from a public gist URL:

gist-import

  1. Try from a Live Editor

live-editor

Furthermore, it features storing the Gist Id or the code string in the localStorage, giving the flexibility of visiting the docs site.

  1. Storing Gist Id in localStorage

stored-gist

  1. Storing the code string in localStorage

stored-code

Last, when importing the Gist ID, it stores the Gist ID to the query param so that you could share the URL to someone else directly:

https://chakra-ui.com/apply-theme?fromGistId=989ad340001061726bf2c0734d3739cf
  1. Read from URL

gits-from-url

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

@changeset-bot
Copy link

changeset-bot bot commented Jun 27, 2021

⚠️ No Changeset found

Latest commit: d419af3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link

vercel bot commented Jun 27, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/chakra-ui/chakra-ui/2e2RPcapcXZDHfHY32EBVBLy3zCD
✅ Preview: Failed

[Deployment for d419af3 failed]

@lgtm-com
Copy link

lgtm-com bot commented Jun 27, 2021

This pull request introduces 4 alerts when merging 24331ed into a08da46 - view on LGTM.com

new alerts:

  • 4 for Unused variable, import, function or class

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 27, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d419af3:

Sandbox Source
create-react-app-ts Configuration

import PageContainer from "components/page-container"
import Sidebar from "components/sidebar/sidebar"
import { getRoutes } from "layouts/mdx"
import _ from "lodash"
Copy link
Contributor

Choose a reason for hiding this comment

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

please use import { last } from 'lodash' or import last from 'lodash.last' as you'd otherwise import the entirety of lodash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ljosberinn Got it and I will update it. Forgot that we don't have babel-plugin-lodash setup here.

I noticed that there are some other places of website that import _ from "lodash" directly so I assume it's okay do to so. I could fix those places in another PR for sure :)

JPEG-1-1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to import last from 'lodash/last'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, I've created a PR to take care of existing imports: #4318

@@ -0,0 +1,229 @@
import { useRouter } from "next/router"
import _ from "lodash"
Copy link
Contributor

Choose a reason for hiding this comment

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

same here :)

@ljosberinn
Copy link
Contributor

Thank you, this is a great idea!

@with-heart with-heart self-assigned this Jun 27, 2021
@with-heart
Copy link
Contributor

Hi @tomchentw! I'd like to echo @ljosberinn here and say that this is a really cool idea. I'd like to take responsibility for thoroughly reviewing this and helping shape this into a solid feature for the site.

Busy this morning but I will have time either later today or tomorrow to dig in. Thanks for working on this!

@lgtm-com
Copy link

lgtm-com bot commented Jun 27, 2021

This pull request introduces 4 alerts when merging 3aa8527 into a08da46 - view on LGTM.com

new alerts:

  • 4 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Jul 1, 2021

This pull request introduces 4 alerts when merging 959bc54 into 7d9cb19 - view on LGTM.com

new alerts:

  • 4 for Unused variable, import, function or class

@tomchentw
Copy link
Contributor Author

JPEG-1

It seems the build process is getting JavaScript heap out of memory error.

@lgtm-com
Copy link

lgtm-com bot commented Jul 6, 2021

This pull request introduces 4 alerts when merging d419af3 into ae27d4f - view on LGTM.com

new alerts:

  • 4 for Unused variable, import, function or class

@segunadebayo
Copy link
Member

This is an awesome idea. I think it makes sense to have it be a separate app or playground so that users can play with it in isolation. I don't think it's something we want to add to the docs directly.

Please consider setting this up in a different URL and we can link to it in the docs.

Thanks for taking the time to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants