Skip to content

Commit a6e2d36

Browse files
authored
fix(sidebar): update type SidebarContext -> SidebarContextProps (#6926)
Hey, I noticed that the original code triggers the `ts/no-redeclare` ESLint error due to the naming conflict between the `SidebarContext` interface and the `SidebarContext` component. ![image](https://github.com/user-attachments/assets/33e6a8de-02bd-43a0-8279-beac8b051602) I think `ts/no-redeclare` is a pretty common ESLint rule, I renamed the interface to `SidebarContextProps` to avoid the conflict. This naming style is consistent with the `carousel` component: (https://github.com/shadcn-ui/ui/blob/0f6efb97698a997c5467eecb8cfed571305f9676/apps/v4/registry/new-york-v4/ui/carousel.tsx#L24). Hope this makes sense!
1 parent 0f6efb9 commit a6e2d36

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

apps/v4/registry/new-york-v4/ui/sidebar.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const SIDEBAR_WIDTH_MOBILE = "18rem"
3232
const SIDEBAR_WIDTH_ICON = "3rem"
3333
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
3434

35-
type SidebarContext = {
35+
type SidebarContextProps = {
3636
state: "expanded" | "collapsed"
3737
open: boolean
3838
setOpen: (open: boolean) => void
@@ -42,7 +42,7 @@ type SidebarContext = {
4242
toggleSidebar: () => void
4343
}
4444

45-
const SidebarContext = React.createContext<SidebarContext | null>(null)
45+
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
4646

4747
function useSidebar() {
4848
const context = React.useContext(SidebarContext)
@@ -113,7 +113,7 @@ function SidebarProvider({
113113
// This makes it easier to style the sidebar with Tailwind classes.
114114
const state = open ? "expanded" : "collapsed"
115115

116-
const contextValue = React.useMemo<SidebarContext>(
116+
const contextValue = React.useMemo<SidebarContextProps>(
117117
() => ({
118118
state,
119119
open,

apps/www/public/r/styles/default/sidebar.json

+2-2
Large diffs are not rendered by default.

apps/www/public/r/styles/new-york-v4/sidebar.json

+2-2
Large diffs are not rendered by default.

apps/www/public/r/styles/new-york/sidebar.json

+2-2
Large diffs are not rendered by default.

apps/www/registry/default/ui/sidebar.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const SIDEBAR_WIDTH_MOBILE = "18rem"
3232
const SIDEBAR_WIDTH_ICON = "3rem"
3333
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
3434

35-
type SidebarContext = {
35+
type SidebarContextProps = {
3636
state: "expanded" | "collapsed"
3737
open: boolean
3838
setOpen: (open: boolean) => void
@@ -42,7 +42,7 @@ type SidebarContext = {
4242
toggleSidebar: () => void
4343
}
4444

45-
const SidebarContext = React.createContext<SidebarContext | null>(null)
45+
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
4646

4747
function useSidebar() {
4848
const context = React.useContext(SidebarContext)
@@ -122,7 +122,7 @@ const SidebarProvider = React.forwardRef<
122122
// This makes it easier to style the sidebar with Tailwind classes.
123123
const state = open ? "expanded" : "collapsed"
124124

125-
const contextValue = React.useMemo<SidebarContext>(
125+
const contextValue = React.useMemo<SidebarContextProps>(
126126
() => ({
127127
state,
128128
open,

apps/www/registry/new-york/ui/sidebar.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const SIDEBAR_WIDTH_MOBILE = "18rem"
3232
const SIDEBAR_WIDTH_ICON = "3rem"
3333
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
3434

35-
type SidebarContext = {
35+
type SidebarContextProps = {
3636
state: "expanded" | "collapsed"
3737
open: boolean
3838
setOpen: (open: boolean) => void
@@ -42,7 +42,7 @@ type SidebarContext = {
4242
toggleSidebar: () => void
4343
}
4444

45-
const SidebarContext = React.createContext<SidebarContext | null>(null)
45+
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
4646

4747
function useSidebar() {
4848
const context = React.useContext(SidebarContext)
@@ -122,7 +122,7 @@ const SidebarProvider = React.forwardRef<
122122
// This makes it easier to style the sidebar with Tailwind classes.
123123
const state = open ? "expanded" : "collapsed"
124124

125-
const contextValue = React.useMemo<SidebarContext>(
125+
const contextValue = React.useMemo<SidebarContextProps>(
126126
() => ({
127127
state,
128128
open,

0 commit comments

Comments
 (0)