-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3 - shared studio button improvements (#557)
* fix(CustomToolMenu): support link button in sidebar context * fix(ToolMenuLinkButton): support dark theme
- Loading branch information
Showing
4 changed files
with
53 additions
and
21 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,12 +1,17 @@ | ||
import { ToolMenuProps } from "sanity"; | ||
import { Inline } from "@sanity/ui"; | ||
import { LinkButton } from "./linkButton/LinkButton"; | ||
import { Inline, Stack } from "@sanity/ui"; | ||
import { ToolMenuLinkButton } from "./toolMenuLinkButton/ToolMenuLinkButton"; | ||
|
||
export default function CustomToolMenu(props: ToolMenuProps) { | ||
const Wrapper = props.context === "topbar" ? Inline : Stack; | ||
return ( | ||
<Inline> | ||
<Wrapper space={4}> | ||
{props.renderDefault(props)} | ||
<LinkButton value="/shared" /> | ||
</Inline> | ||
<ToolMenuLinkButton | ||
value={"/shared"} | ||
label={"Shared Studio"} | ||
context={props.context} | ||
/> | ||
</Wrapper> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
studio/components/toolMenuLinkButton/ToolMenuLinkButton.tsx
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,25 @@ | ||
import styles from "./toolMenuLinkButton.module.css"; | ||
import { useTheme } from "@sanity/ui"; | ||
|
||
interface LinkButtonProps { | ||
label: string; | ||
value?: string; | ||
context: "topbar" | "sidebar"; | ||
} | ||
|
||
export const ToolMenuLinkButton = ({ | ||
label, | ||
value, | ||
context, | ||
}: LinkButtonProps) => { | ||
const theme = useTheme(); | ||
const prefersDark = theme.sanity.v2?.color._dark ?? false; | ||
return ( | ||
<a | ||
className={`${styles.wrapper}${context === "sidebar" ? ` ${styles.inSidebar}` : ""}${prefersDark ? ` ${styles.darkTheme}` : ""}`} | ||
href={value} | ||
> | ||
<span className={styles.text}>{label}</span> | ||
</a> | ||
); | ||
}; |
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