-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5617f1b
commit f7d989b
Showing
7 changed files
with
32 additions
and
25 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export {useDocumentPresence, useGlobalPresence} from './datastores/presence/hooks' | ||
export {useUser} from './datastores/user/hooks' | ||
export {useUserColor} from './user-color/useUserColor' | ||
export {useUserColor} from './user-color/hooks' | ||
export {useTimeAgo} from './time/useTimeAgo' |
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 @@ | ||
import {createContext} from 'react' | ||
import {userColorManager} from './singleton' | ||
import {UserColorManager} from './types' | ||
|
||
export const UserColorManagerContext = createContext<UserColorManager>(userColorManager) |
9 changes: 7 additions & 2 deletions
9
...anity/base/src/user-color/useUserColor.ts → ...ages/@sanity/base/src/user-color/hooks.ts
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export {createUserColorManager} from './manager' | ||
export {useUserColorManager, UserColorManagerProvider} from './provider' | ||
export {userColorManager} from './singleton' | ||
export {useUserColor} from './useUserColor' | ||
export * from './hooks' | ||
export * from './manager' | ||
export * from './provider' | ||
export * from './singleton' | ||
export * from './types' |
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 |
---|---|---|
@@ -1,18 +1,15 @@ | ||
import React, {createContext, useContext} from 'react' | ||
import React from 'react' | ||
import {UserColorManagerContext} from './context' | ||
import {UserColorManager} from './types' | ||
import {userColorManager} from './singleton' | ||
|
||
interface ProviderProps { | ||
interface UserColorManagerProviderProps { | ||
children: React.ReactNode | ||
manager: UserColorManager | ||
} | ||
|
||
const UserColorManagerContext = createContext<UserColorManager>(userColorManager) | ||
|
||
export function useUserColorManager(): UserColorManager { | ||
return useContext(UserColorManagerContext) | ||
} | ||
|
||
export function UserColorManagerProvider({children, manager}: ProviderProps) { | ||
export function UserColorManagerProvider({ | ||
children, | ||
manager | ||
}: UserColorManagerProviderProps): React.ReactElement { | ||
return React.createElement(UserColorManagerContext.Provider, {value: manager}, children) | ||
} |
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