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

v3 - shared studio button improvements #557

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 10 additions & 5 deletions studio/components/CustomToolMenu.tsx
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>
);
}
14 changes: 0 additions & 14 deletions studio/components/linkButton/LinkButton.tsx

This file was deleted.

25 changes: 25 additions & 0 deletions studio/components/toolMenuLinkButton/ToolMenuLinkButton.tsx
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>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@
padding: 0.2rem 0.5rem;
}

.wrapper.inSidebar {
padding: 0.5rem 0.75rem;
}

.wrapper:hover {
background: #f5f5f7;
}

.darkTheme.wrapper:hover {
background: #191a24;
}

.text {
display: flex;
align-items: center;
text-decoration: block;
font-weight: 500;
color: #323545;
letter-spacing: 0;
font-size: 13px;
gap: 0.2rem;
line-height: 19px;
font-size: 0.8125rem;
line-height: calc(19 / 13);

&::after {
content: "";
Expand All @@ -32,3 +40,11 @@
background-color: #323545;
}
}

.darkTheme .text {
color: #bec0cd;

&::after {
background-color: #bec0cd;
}
}