mirror of
https://github.com/outline/outline.git
synced 2026-12-05 02:44:34 +03:00
Lighter menu headers and remove dividers above groups (#14679)
* Update menu header style and strip dividers above groups * Reduce font-size * Ignore hidden menu elements when removing the first header margin
This commit is contained in:
1 parent
1bac711141
commit
c88ea4b0d2
7 files changed
+79
-15
No files matched your search
@@ -200,7 +200,10 @@ export function MenuFilter({ query, onChange }: Props) {
|
||||
);
|
||||
|
||||
return (
|
||||
<Wrapper style={isActive ? undefined : VISUALLY_HIDDEN_STYLES}>
|
||||
<Wrapper
|
||||
style={isActive ? undefined : VISUALLY_HIDDEN_STYLES}
|
||||
data-menu-hidden={isActive ? undefined : ""}
|
||||
>
|
||||
<Input
|
||||
value={query ?? ""}
|
||||
onChange={handleChange}
|
||||
|
||||
@@ -19,8 +19,8 @@ const items: MenuItem[] = [
|
||||
{ type: "button", title: "Hidden date", visible: false, onClick: noop },
|
||||
];
|
||||
|
||||
function render(query?: string) {
|
||||
return (toMenuItems(items, query) ?? []).filter(
|
||||
function render(query?: string, menuItems = items) {
|
||||
return (toMenuItems(menuItems, query) ?? []).filter(
|
||||
(element): element is ReactElement => !!element
|
||||
);
|
||||
}
|
||||
@@ -47,4 +47,33 @@ describe("toMenuItems", () => {
|
||||
it("returns null when nothing matches", () => {
|
||||
expect(toMenuItems(items, "zzz")).toBeNull();
|
||||
});
|
||||
|
||||
it("removes a separator above a group", () => {
|
||||
const keys = render(undefined, [
|
||||
{ type: "button", title: "Team", onClick: noop },
|
||||
{ type: "separator" },
|
||||
{
|
||||
type: "group",
|
||||
title: "Group",
|
||||
items: [{ type: "button", title: "Design", onClick: noop }],
|
||||
},
|
||||
]).map((element) => element.key);
|
||||
expect(keys).toEqual(["button-0", "group-1"]);
|
||||
});
|
||||
|
||||
it("keeps a separator above a group that has no visible items", () => {
|
||||
const keys = render(undefined, [
|
||||
{ type: "button", title: "Team", onClick: noop },
|
||||
{ type: "separator" },
|
||||
{
|
||||
type: "group",
|
||||
title: "Group",
|
||||
items: [
|
||||
{ type: "button", title: "Design", visible: false, onClick: noop },
|
||||
],
|
||||
},
|
||||
{ type: "button", title: "Due date", onClick: noop },
|
||||
]).map((element) => element.key);
|
||||
expect(keys).toEqual(["button-0", "separator-1", "button-2"]);
|
||||
});
|
||||
});
|
||||
@@ -290,7 +290,7 @@ export function toMobileMenuItems(
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={`${item.type}-${index}`}>
|
||||
<div key={`${item.type}-${index}`} role="group">
|
||||
<Components.MenuHeader>{item.title}</Components.MenuHeader>
|
||||
{groupItems}
|
||||
</div>
|
||||
@@ -340,7 +340,11 @@ function matchesQuery(item: MenuItem, query: string): boolean {
|
||||
|
||||
function filterMenuItems(items: MenuItem[]): MenuItem[] {
|
||||
return items
|
||||
.filter((item) => item.visible !== false)
|
||||
.filter(
|
||||
(item) =>
|
||||
item.visible !== false &&
|
||||
(item.type !== "group" || filterMenuItems(item.items).length > 0)
|
||||
)
|
||||
.reduce((acc, item) => {
|
||||
// trim separator when the previous item is also a separator.
|
||||
if (
|
||||
@@ -352,10 +356,12 @@ function filterMenuItems(items: MenuItem[]): MenuItem[] {
|
||||
return [...acc, item];
|
||||
}, [] as MenuItem[])
|
||||
.filter((item, index, arr) => {
|
||||
// trim when first or last item is a separator.
|
||||
// trim when first or last item is a separator, or above a group header.
|
||||
if (
|
||||
item.type === "separator" &&
|
||||
(index === 0 || index === arr.length - 1)
|
||||
(index === 0 ||
|
||||
index === arr.length - 1 ||
|
||||
arr[index + 1]?.type === "group")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ export const MouseSafeArea = observer(function MouseSafeArea_(props: {
|
||||
|
||||
return (
|
||||
<div
|
||||
data-menu-hidden=""
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
|
||||
@@ -128,13 +128,22 @@ export const MenuLabel = styled.div`
|
||||
`;
|
||||
|
||||
export const MenuHeader = styled.h3`
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: ${s("sidebarText")};
|
||||
letter-spacing: 0.04em;
|
||||
margin: 1em 12px 0.5em;
|
||||
user-select: none;
|
||||
|
||||
// Remove the top margin when nothing visible is above the header, except in
|
||||
// the mobile drawer, which has less padding.
|
||||
${breakpoint("tablet")`
|
||||
&:first-child:not([role="group"] > *),
|
||||
[data-menu-hidden]:first-child + &,
|
||||
[role="group"]:first-child > &:first-child,
|
||||
[data-menu-hidden]:first-child + [role="group"] > &:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
export const MenuDisclosure = styled(ExpandedIcon)`
|
||||
|
||||
@@ -24,7 +24,8 @@ type Props = {
|
||||
* they are published and organizes them into appropriate sections.
|
||||
*
|
||||
* Collection-specific templates are displayed first, followed by workspace templates
|
||||
* with a separator in between (if both types exist).
|
||||
* in a group with a separator in between. Workspace templates are not grouped
|
||||
* when there are no collection-specific templates.
|
||||
*
|
||||
* @returns An array of Action objects representing templates that can be applied
|
||||
* to the current document. Returns an empty array if no callback is provided.
|
||||
@@ -90,6 +91,10 @@ export function useTemplateMenuActions({
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!collectionTemplatesActions.length) {
|
||||
return workspaceTemplatesActions;
|
||||
}
|
||||
|
||||
return [
|
||||
...collectionTemplatesActions,
|
||||
ActionSeparator,
|
||||
|
||||
@@ -733,6 +733,7 @@
|
||||
"Integrations": "Integrations",
|
||||
"Back to app": "Back to app",
|
||||
"Installation": "Installation",
|
||||
"Available on {{ planName }}": "Available on {{ planName }}",
|
||||
"Split pane": "Split pane",
|
||||
"Main pane": "Main pane",
|
||||
"Unstar document": "Unstar document",
|
||||
@@ -896,6 +897,11 @@
|
||||
"Upload a video": "Upload a video",
|
||||
"Edit video URL": "Edit video URL",
|
||||
"Could not import file": "Could not import file",
|
||||
"Community": "Community",
|
||||
"Standard": "Standard",
|
||||
"Business": "Business",
|
||||
"Enterprise": "Enterprise",
|
||||
"Legacy": "Legacy",
|
||||
"Unsubscribed from document": "Unsubscribed from document",
|
||||
"Unsubscribed from collection": "Unsubscribed from collection",
|
||||
"Subscription successful": "Subscription successful",
|
||||
@@ -1466,6 +1472,8 @@
|
||||
"This color has low contrast against the accent color": "This color has low contrast against the accent color",
|
||||
"Accent color": "Accent color",
|
||||
"Accent text color": "Accent text color",
|
||||
"This feature is included in {{planName}} and above. Upgrade your workspace to unlock it for your team.": "This feature is included in {{planName}} and above. Upgrade your workspace to unlock it for your team.",
|
||||
"View plans": "View plans",
|
||||
"All roles": "All roles",
|
||||
"Admins": "Admins",
|
||||
"Editors": "Editors",
|
||||
@@ -1520,7 +1528,6 @@
|
||||
"Import a zip file of Markdown documents in the Open Knowledge Format": "Import a zip file of Markdown documents in the Open Knowledge Format",
|
||||
"Import a JSON data file exported from another {{ appName }} instance": "Import a JSON data file exported from another {{ appName }} instance",
|
||||
"Import pages from a Confluence instance": "Import pages from a Confluence instance",
|
||||
"Enterprise": "Enterprise",
|
||||
"Quickly transfer your existing documents, pages, and files from other tools and services into {{appName}}. You can also drag and drop any HTML, Markdown, and text documents directly into Collections in the app.": "Quickly transfer your existing documents, pages, and files from other tools and services into {{appName}}. You can also drag and drop any HTML, Markdown, and text documents directly into Collections in the app.",
|
||||
"Recent imports": "Recent imports",
|
||||
"Configure a variety of integrations with third-party services.": "Configure a variety of integrations with third-party services.",
|
||||
@@ -1677,7 +1684,7 @@
|
||||
"Failed to save revision": "Failed to save revision",
|
||||
"Invite to document": "Invite to document",
|
||||
"Sorry, invalid embed link": "Sorry, invalid embed link",
|
||||
"Data Attributes": "Data Attributes",
|
||||
"Data attributes": "Data attributes",
|
||||
"Edit attribute": "Edit attribute",
|
||||
"Property": "Property",
|
||||
"Yes": "Yes",
|
||||
@@ -1709,7 +1716,7 @@
|
||||
"Text": "Text",
|
||||
"List": "List",
|
||||
"Could not load events": "Could not load events",
|
||||
"Audit Log": "Audit Log",
|
||||
"Audit log": "Audit log",
|
||||
"The audit log details the history of security-related and other events across your knowledge base.": "The audit log details the history of security-related and other events across your knowledge base.",
|
||||
"IP address": "IP address",
|
||||
"Actor": "Actor",
|
||||
@@ -1852,6 +1859,10 @@
|
||||
"Script name": "Script name",
|
||||
"The name of the script file that Umami uses to track analytics.": "The name of the script file that Umami uses to track analytics.",
|
||||
"An ID that uniquely identifies the website in your Umami instance.": "An ID that uniquely identifies the website in your Umami instance.",
|
||||
"The audit log details the history of security related and other events across your knowledge base.": "The audit log details the history of security related and other events across your knowledge base.",
|
||||
"Content": "Content",
|
||||
"Manage the permissions and settings of all collections in the knowledge base. As a workspace admin you can also administer private collections.": "Manage the permissions and settings of all collections in the knowledge base. As a workspace admin you can also administer private collections.",
|
||||
"Automatically index and search document content from {{appName}} inside Glean in realtime.": "Automatically index and search document content from {{appName}} inside Glean in realtime.",
|
||||
"New webhook": "New webhook",
|
||||
"Edit webhook": "Edit webhook",
|
||||
"Delete webhook": "Delete webhook",
|
||||
|
||||
Reference in new issue
Block a user