mirror of
https://github.com/docmost/docmost.git
synced 2025-11-12 17:52:37 +10:00
css fixes
This commit is contained in:
@ -2,13 +2,13 @@ import { Box, ScrollArea, Text } from "@mantine/core";
|
|||||||
import CommentList from "@/features/comment/components/comment-list.tsx";
|
import CommentList from "@/features/comment/components/comment-list.tsx";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { asideStateAtom } from "@/components/navbar/atoms/sidebar-atom.ts";
|
import { asideStateAtom } from "@/components/navbar/atoms/sidebar-atom.ts";
|
||||||
import React from "react";
|
import React, { ReactNode } from "react";
|
||||||
|
|
||||||
export default function Aside() {
|
export default function Aside() {
|
||||||
const [{ tab }] = useAtom(asideStateAtom);
|
const [{ tab }] = useAtom(asideStateAtom);
|
||||||
|
|
||||||
let title;
|
let title: string;
|
||||||
let component;
|
let component: ReactNode;
|
||||||
|
|
||||||
switch (tab) {
|
switch (tab) {
|
||||||
case "comments":
|
case "comments":
|
||||||
|
|||||||
@ -8,9 +8,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.aside {
|
.aside {
|
||||||
@media (min-width: 993px) {
|
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-8));
|
||||||
background: var(--mantine-color-gray-light);
|
|
||||||
|
|
||||||
|
@media (min-width: 993px) {
|
||||||
[data-layout="alt"] & {
|
[data-layout="alt"] & {
|
||||||
--_section-top: var(--_section-top, var(--app-shell-header-offset, 0px));
|
--_section-top: var(--_section-top, var(--app-shell-header-offset, 0px));
|
||||||
--_section-height: var(
|
--_section-height: var(
|
||||||
@ -35,3 +35,4 @@
|
|||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,7 @@ export default function Shell({ children }: { children: React.ReactNode }) {
|
|||||||
<AppShell.Main>{children}</AppShell.Main>
|
<AppShell.Main>{children}</AppShell.Main>
|
||||||
|
|
||||||
{isPageRoute && (
|
{isPageRoute && (
|
||||||
<AppShell.Aside className={classes.aside}>
|
<AppShell.Aside className={classes.aside} withBorder={false}>
|
||||||
<Aside />
|
<Aside />
|
||||||
</AppShell.Aside>
|
</AppShell.Aside>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
.navbar {
|
.navbar {
|
||||||
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-7));
|
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-8));
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: var(--mantine-spacing-md);
|
padding: var(--mantine-spacing-md);
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border-right: rem(1px) solid light-dark('', var(--mantine-color-dark-4));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
|
|||||||
@ -1,30 +1,18 @@
|
|||||||
import {
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
useCallback,
|
|
||||||
useEffect,
|
|
||||||
useMemo,
|
|
||||||
useRef,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
import {
|
import {
|
||||||
SlashMenuGroupedItemsType,
|
SlashMenuGroupedItemsType,
|
||||||
SlashMenuItemType,
|
SlashMenuItemType,
|
||||||
} from '@/features/editor/components/slash-menu/types';
|
} from "@/features/editor/components/slash-menu/types";
|
||||||
import {
|
import { Group, Paper, ScrollArea, Text, UnstyledButton } from "@mantine/core";
|
||||||
Group,
|
import classes from "./slash-menu.module.css";
|
||||||
Paper,
|
import clsx from "clsx";
|
||||||
ScrollArea,
|
|
||||||
Text,
|
|
||||||
UnstyledButton,
|
|
||||||
} from '@mantine/core';
|
|
||||||
import classes from './slash-menu.module.css';
|
|
||||||
import clsx from 'clsx';
|
|
||||||
|
|
||||||
const CommandList = ({
|
const CommandList = ({
|
||||||
items,
|
items,
|
||||||
command,
|
command,
|
||||||
editor,
|
editor,
|
||||||
range,
|
range,
|
||||||
}: {
|
}: {
|
||||||
items: SlashMenuGroupedItemsType;
|
items: SlashMenuGroupedItemsType;
|
||||||
command: any;
|
command: any;
|
||||||
editor: any;
|
editor: any;
|
||||||
@ -48,31 +36,33 @@ const CommandList = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const navigationKeys = ['ArrowUp', 'ArrowDown', 'Enter'];
|
const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
|
||||||
const onKeyDown = (e: KeyboardEvent) => {
|
const onKeyDown = (e: KeyboardEvent) => {
|
||||||
if (navigationKeys.includes(e.key)) {
|
if (navigationKeys.includes(e.key)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (e.key === 'ArrowUp') {
|
if (e.key === "ArrowUp") {
|
||||||
setSelectedIndex((selectedIndex + flatItems.length - 1) % flatItems.length);
|
setSelectedIndex(
|
||||||
|
(selectedIndex + flatItems.length - 1) % flatItems.length,
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === 'ArrowDown') {
|
if (e.key === "ArrowDown") {
|
||||||
setSelectedIndex((selectedIndex + 1) % flatItems.length);
|
setSelectedIndex((selectedIndex + 1) % flatItems.length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === 'Enter') {
|
if (e.key === "Enter") {
|
||||||
selectItem(selectedIndex);
|
selectItem(selectedIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.addEventListener('keydown', onKeyDown);
|
document.addEventListener("keydown", onKeyDown);
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener('keydown', onKeyDown);
|
document.removeEventListener("keydown", onKeyDown);
|
||||||
};
|
};
|
||||||
}, [flatItems, selectedIndex, setSelectedIndex, selectItem]);
|
}, [flatItems, selectedIndex, setSelectedIndex, selectItem]);
|
||||||
|
|
||||||
@ -83,11 +73,11 @@ const CommandList = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
viewportRef.current
|
viewportRef.current
|
||||||
?.querySelector(`[data-item-index="${selectedIndex}"]`)
|
?.querySelector(`[data-item-index="${selectedIndex}"]`)
|
||||||
?.scrollIntoView({ block: 'nearest' });
|
?.scrollIntoView({ block: "nearest" });
|
||||||
}, [selectedIndex]);
|
}, [selectedIndex]);
|
||||||
|
|
||||||
return flatItems.length > 0 ? (
|
return flatItems.length > 0 ? (
|
||||||
<Paper id="slash-command" shadow="xl" p="sm" withBorder>
|
<Paper id="slash-command" shadow="md" p="xs" withBorder>
|
||||||
<ScrollArea viewportRef={viewportRef} h={350} w={250} scrollbarSize={5}>
|
<ScrollArea viewportRef={viewportRef} h={350} w={250} scrollbarSize={5}>
|
||||||
{Object.entries(items).map(([category, categoryItems]) => (
|
{Object.entries(items).map(([category, categoryItems]) => (
|
||||||
<div key={category}>
|
<div key={category}>
|
||||||
@ -99,16 +89,12 @@ const CommandList = ({
|
|||||||
data-item-index={index}
|
data-item-index={index}
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => selectItem(index)}
|
onClick={() => selectItem(index)}
|
||||||
className={clsx(classes.menuBtn, { [classes.selectedItem]: index === selectedIndex })}
|
className={clsx(classes.menuBtn, {
|
||||||
style={{
|
[classes.selectedItem]: index === selectedIndex,
|
||||||
width: '100%',
|
})}
|
||||||
padding: 'var(--mantine-spacing-xs)',
|
|
||||||
color: 'var(--mantine-color-text)',
|
|
||||||
borderRadius: 'var(--mantine-radius-sm)',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Group>
|
<Group>
|
||||||
<item.icon size={18} />
|
<item.icon size={16} />
|
||||||
|
|
||||||
<div style={{ flex: 1 }}>
|
<div style={{ flex: 1 }}>
|
||||||
<Text size="sm" fw={500}>
|
<Text size="sm" fw={500}>
|
||||||
|
|||||||
@ -1,21 +1,27 @@
|
|||||||
.menuBtn {
|
.menuBtn {
|
||||||
&:hover {
|
width: 100%;
|
||||||
@mixin light {
|
padding: 4px;
|
||||||
background: var(--mantine-color-gray-2);
|
margin-bottom: 2px;
|
||||||
}
|
color: var(--mantine-color-text);
|
||||||
|
border-radius: var(--mantine-radius-sm);
|
||||||
|
|
||||||
@mixin dark {
|
&:hover {
|
||||||
background: var(--mantine-color-gray-light);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.selectedItem {
|
|
||||||
@mixin light {
|
@mixin light {
|
||||||
background: var(--mantine-color-gray-2);
|
background: var(--mantine-color-gray-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin dark {
|
@mixin dark {
|
||||||
background: var(--mantine-color-gray-light);
|
background: var(--mantine-color-gray-light);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.selectedItem {
|
||||||
|
@mixin light {
|
||||||
|
background: var(--mantine-color-gray-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin dark {
|
||||||
|
background: var(--mantine-color-gray-light);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,6 +95,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.comment-mark {
|
.comment-mark {
|
||||||
background: rgba(0,203,15,0.2);
|
background: rgba(255, 215, 0, .14);
|
||||||
border-bottom: 2px solid #0ca678;
|
border-bottom: 2px solid rgb(166, 158, 12);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user