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

Add ModeToggleGroup Component and Update Documentation #2

Merged
merged 28 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e38fed9
✨ feat(docs): add examples for mode toggle using Dropdown Menu and To…
nyxb Jul 7, 2024
7bb1fcb
🤖 ci: update pnpm version in GitHub Actions workflow to 9.4.0
nyxb Jul 7, 2024
b9a887b
🤖 ci: update pnpm/action-setup to v4 and pnpm version to 9.4.0 in wor…
nyxb Jul 7, 2024
8fab9e9
🤖 ci: update Node.js version to 20 in GitHub Actions workflow
nyxb Jul 7, 2024
8c2c476
🤖 ci(code-check.yml): update eslint:fix script to lint:fix for consis…
nyxb Jul 7, 2024
8c75c1c
🧹 chore(workflows): rename pnpm typecheck job to pnpm check
nyxb Jul 7, 2024
3115505
🤖 ci(code-check.yml): change pnpm typecheck to pnpm check for consist…
nyxb Jul 7, 2024
ed08ebd
✨ feat(turbo.json): add typecheck script configuration
nyxb Jul 7, 2024
ceb3340
🧹 chore(icons.tsx): remove unused InstagramLogoIcon import
nyxb Jul 7, 2024
9a7f4c7
🧩 elements(settings.json): add new file associations for better navig…
nyxb Jul 7, 2024
2e92176
🤖 ci(workflows): add step to create .env file from secrets in code-ch…
nyxb Jul 7, 2024
c2e0dd6
🤖 ci(workflows): downgrade Node.js to v18 and pnpm to v8.11.0 for com…
nyxb Jul 7, 2024
9769baa
🧹 chore(workflows): remove specific pnpm version from code-check.yml
nyxb Jul 7, 2024
62e40dc
🩹 fix(package.json): downgrade pnpm version from 9.4.0 to 9.0.6 for c…
nyxb Jul 7, 2024
664c449
🤖 ci(workflows): update pnpm action to v4 and specify version 9.0.6
nyxb Jul 7, 2024
5e5f905
🩹 fix(package.json): separate lint and typecheck commands for clarity
nyxb Jul 8, 2024
981ca25
ci:🤖 update GitHub Actions workflow to use pnpm lint:fix instead of f…
nyxb Jul 8, 2024
de2906b
🩹 fix(package.json): remove redundant build:env command from typechec…
nyxb Jul 8, 2024
57fd485
🤖 ci(workflows): add steps to create and load .env file in GitHub Act…
nyxb Jul 8, 2024
d1a9875
🤖 ci(code-check.yml): add environment variable loading for lint, lint…
nyxb Jul 8, 2024
221363d
🤖 ci: add workflow to close inactive issues and PRs
nyxb Jul 8, 2024
c75d89b
⬆️ upgrade(package.json): update pnpm to version 9.4.0
nyxb Jul 8, 2024
7b84beb
🤖 ci(test.yml): update pnpm/action-setup to v4 and pnpm version to 9.4.0
nyxb Jul 8, 2024
42b77cf
🧹 chore(.nvmrc): update Node.js version to v20.5.1
nyxb Jul 8, 2024
0c6d9ee
🩹 fix(package.json): remove redundant build:registry script from buil…
nyxb Jul 8, 2024
7e53ee7
🧹 chore(.nvmrc): downgrade Node.js version from v20.5.1 to v18.20.3
nyxb Jul 8, 2024
d07b50b
🛠️ build(.nvmrc): update Node.js version to v20.14.0
nyxb Jul 8, 2024
02694f0
🩹 fix(page.tsx): correct import extension from .mjs to .mts
nyxb Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/close-issue-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Close Inactive Issues
on:
schedule:
- cron: "0 0 * * *"

jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 60
days-before-issue-close: 14
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 60 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
# close-pr-message: "This pull request is stale because it has been open for -- days with no activity."
# stale-pr-message: "This pull request was closed because it has been inactive for -- days since being marked as stale."
exempt-issue-labels: "bug,enhancement"
exempt-pr-labels: "bug,enhancement"
repo-token: ${{ secrets.GITHUB_TOKEN }}
50 changes: 7 additions & 43 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
with:
node-version: 18

- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8.6.1
version: 9.4.0
run_install: false

- name: Get pnpm store directory
Expand All @@ -39,49 +39,13 @@ jobs:
- name: Install dependencies
run: pnpm install

- run: pnpm lint:fix

eslint_fix:
runs-on: ubuntu-latest
name: pnpm lint:fix
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8.6.1
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- run: pnpm eslint:fix
- run: pnpm lint

tsc:
runs-on: ubuntu-latest
name: pnpm typecheck
env:
NEXT_PUBLIC_APP_URL: http://localhost:3001
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -92,11 +56,11 @@ jobs:
with:
node-version: 18

- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8.6.1
version: 9.4.0
run_install: false

- name: Get pnpm store directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
with:
node-version: 18

- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8.6.1
version: 9.4.0
run_install: false

- name: Get pnpm store directory
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/welcome-contributor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
- name: "Greet the contributor"
uses: actions/first-interaction@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
is-oauth-token: true
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "Hello there 👋 Thanks for opening your first issue. We welcome you to the ${{ github.event.repository.name }} community! 😊"
pr-message: "Hello there 👋 Thanks for opening your first Pull Request. Someone will review it soon. 😉"
11 changes: 7 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@
"**/app/**/layout.tsx": "${dirname(1)}/${dirname} <layout />",
"**/app/**/route.ts": "${dirname(1)}/${dirname} <route />",
"**/components/**/*.tsx": "${dirname(1)}/${filename} <component />",
"**/components/**/*.ts": "${dirname(1)}/${filename} <component />"
"**/components/**/*.ts": "${dirname(1)}/${filename} <component />",
"**/package.json": "${dirname(1)}/${dirname} <package.json />",
"**/index.ts": "${dirname(1)}/${dirname} <index.ts />",
"**/tsconfig.json": "${dirname(1)}/${dirname} <tsconfig.json />"
},
"search.useIgnoreFiles": true,
"cSpell.words": [
"pullup",
"shadcn"
]
"pullup",
"shadcn"
]
}
22 changes: 22 additions & 0 deletions apps/web/__registry__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,17 @@ export const Index: Record<string, any> = {
subcategory: 'undefined',
chunks: [],
},
'mode-toggle-group': {
name: 'mode-toggle-group',
type: 'components:example',
registryDependencies: undefined,
component: React.lazy(() => import('~/registry/default/example/mode-toggle-group')),
source: '',
files: ['registry/default/example/mode-toggle-group.tsx'],
category: 'undefined',
subcategory: 'undefined',
chunks: [],
},
'tooltip-demo': {
name: 'tooltip-demo',
type: 'components:example',
Expand Down Expand Up @@ -7335,6 +7346,17 @@ export const Index: Record<string, any> = {
subcategory: 'undefined',
chunks: [],
},
'mode-toggle-group': {
name: 'mode-toggle-group',
type: 'components:example',
registryDependencies: undefined,
component: React.lazy(() => import('~/registry/miami/example/mode-toggle-group')),
source: '',
files: ['registry/miami/example/mode-toggle-group.tsx'],
category: 'undefined',
subcategory: 'undefined',
chunks: [],
},
'tooltip-demo': {
name: 'tooltip-demo',
type: 'components:example',
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/(marketing)/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { Mdx } from '~/components/mdx-components'
import { siteConfig } from '~/config/site'
import { env } from '~/scripts/env.mjs'
import { env } from '~/scripts/env.mts'
import { absoluteUrl } from '~/lib/utils'
import '~/styles/mdx.css'

Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DiscordLogoIcon, InstagramLogoIcon } from '@radix-ui/react-icons'
import { DiscordLogoIcon } from '@radix-ui/react-icons'
import {
AlertTriangle,
ArrowRight,
Expand Down
72 changes: 72 additions & 0 deletions apps/web/content/docs/dark-mode/astro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,76 @@ export function ModeToggle() {
}
```

**Example 1** using Dropdown Menu

in this example, we will use a `Dropdown Menu` component to toggle between light, dark mode.

```tsx title="src/components/ModeToggle.tsx"
import * as React from "react"
import { Moon, Sun } from "lucide-react"
@@ -98,6 +102,65 @@ export function ModeToggle() {
}
```

**Example 2** using Toggle Group

in this example, we will use a `Toggle Group` component to toggle between light, dark mode. also, we can change `scale` of this for smaller view.

```tsx title="src/components/ModeToggle.tsx"
import * as React from "react"
import { Sun, Moon, Laptop } from "lucide-react"

import {
ToggleGroup,
ToggleGroupItem
} from "@/components/ui/toggle-group"

export function ModeToggle() {
const [theme, setThemeState] = React.useState<
"theme-light" | "dark" | "system"
>("theme-light")

React.useEffect(() => {
const isDarkMode = document.documentElement.classList.contains("dark")
setThemeState(isDarkMode ? "dark" : "theme-light")
}, [])

React.useEffect(() => {
const isDark =
theme === "dark" ||
(theme === "system" &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
document.documentElement.classList[isDark ? "add" : "remove"]("dark")
}, [theme])

return (
<ToggleGroup type="single" className="border p-1 rounded-full">
<ToggleGroupItem
value="Light"
className="rounded-full"
onClick={() => setThemeState("theme-light")}
>
<Sun className="h-5 w-5" />
</ToggleGroupItem>
<ToggleGroupItem
value="System"
className="rounded-full"
onClick={() => setThemeState("system")}
>
<Laptop className="h-5 w-5" />
</ToggleGroupItem>
<ToggleGroupItem
value="Dark"
className="rounded-full"
onClick={() => setThemeState("dark")}
>
<Moon className="h-5 w-5" />
</ToggleGroupItem>
</ToggleGroup>
)
}
```

### Display the mode toggle

Place a mode toggle on your site to toggle between light and dark mode.
Expand All @@ -119,3 +189,5 @@ import { ModeToggle } from '@/components/ModeToggle';
```

</Steps>


12 changes: 12 additions & 0 deletions apps/web/content/docs/dark-mode/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ export default function RootLayout({ children }: RootLayoutProps) {

### Add a mode toggle

**Example 1** using Dropdown Menu

in this example, we will use a `Dropdown Menu` component to toggle between light, dark mode.

<ComponentPreview name="mode-toggle" className="[&_.preview]:items-start" styleSwitch={true} button="copy" dots={false} />

**Example 2** using Toggle Group

in this example, we will use a `Toggle Group` component to toggle between light, dark mode. also, we can change `scale` of this for smaller view.

<ComponentPreview name="mode-toggle-group" className="[&_.preview]:items-start" styleSwitch={true} button="copy" dots={false} />

Place a mode toggle on your site to toggle between light and dark mode.

<ComponentPreview name="mode-toggle" className="[&_.preview]:items-start" styleSwitch={true} button="copy" dots={false} />
Expand Down
55 changes: 55 additions & 0 deletions apps/web/content/docs/dark-mode/remix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,61 @@ export const action = createThemeAction(themeSessionResolver)

### Add a mode toggle

**Example 1** using Dropdown Menu

in this example, we will use a `Dropdown Menu` component to toggle between light, dark mode.

```tsx title="components/mode-toggle.tsx"
import { Moon, Sun } from "lucide-react"
@@ -132,7 +134,7 @@ import {
} from "./ui/dropdown-menu"

export function ModeToggle() {
const [ setTheme ] = useTheme()

return (
<DropdownMenu>
@@ -156,4 +158,41 @@ export function ModeToggle() {
}
```

**Example 2** using Toggle Group

in this example, we will use a `Toggle Group` component to toggle between light, dark mode. also, we can change `scale` of this for smaller view.

```tsx title="components/mode-toggle.tsx"
import { Moon, Sun } from "lucide-react"
import { Theme, useTheme } from "remix-themes"

import {
ToggleGroup,
ToggleGroupItem
} from "@/components/ui/toggle-group"

export function ModeToggle() {
const [ setTheme ] = useTheme()

return (
<ToggleGroup type="single" className="border p-1 rounded-full">
<ToggleGroupItem
value="Light"
className="rounded-full"
onClick={() => setTheme(Theme.LIGHT)}
>
<Sun className="h-5 w-5" />
</ToggleGroupItem>
<ToggleGroupItem
value="Dark"
className="rounded-full"
onClick={() => setTheme(Theme.DARK)}
>
<Moon className="h-5 w-5" />
</ToggleGroupItem>
</ToggleGroup>
)
}
```

Place a mode toggle on your site to toggle between light and dark mode.

```tsx title="components/mode-toggle.tsx"
Expand Down
Loading
Loading