From ccfcaa590b016ccafe8ea7303e0d185adecd1d8c Mon Sep 17 00:00:00 2001 From: Sebastian Graz Date: Thu, 4 Jan 2024 18:43:37 +0100 Subject: [PATCH] Style PR (#84) * fixes for table values * color tweaks rating * inc legibility on aside active * add tab separators * fix hint icon * fix header colors & remove custom balance * Better mobile burger colors * remove border from logofallback img * style divider dark mode * compact header + file + expandable hover + mt mobile nav * testing file types --- src/app/[spaceId]/globals.css | 8 +- src/components/Cookies/CookiesToast.tsx | 2 +- src/components/DocumentView/Divider.tsx | 2 +- .../DocumentView/Expandable/Expandable.tsx | 10 +- src/components/DocumentView/File.tsx | 93 +++++++++++++++++-- .../DocumentView/Table/RecordColumnValue.tsx | 46 ++++++--- .../DocumentView/Table/RecordRow.tsx | 2 +- .../DocumentView/Table/ViewGrid.tsx | 2 +- .../DocumentView/Tabs/DynamicTabs.tsx | 31 ++++++- src/components/Header/CompactHeader.tsx | 1 + src/components/Header/Header.tsx | 17 ++-- src/components/Header/HeaderLogo.tsx | 17 +++- src/components/Header/HeaderMobileMenu.tsx | 5 +- .../PageAside/ScrollSectionsList.tsx | 4 +- src/components/Search/SearchButton.tsx | 2 + .../TableOfContents/TableOfContents.tsx | 2 +- .../TableOfContents/ToggleableLinkItem.tsx | 2 +- src/components/primitives/Link.tsx | 1 + src/components/primitives/LoadingPane.tsx | 2 +- tailwind.config.ts | 2 +- 20 files changed, 195 insertions(+), 56 deletions(-) diff --git a/src/app/[spaceId]/globals.css b/src/app/[spaceId]/globals.css index 88daf3803..e58457c7f 100644 --- a/src/app/[spaceId]/globals.css +++ b/src/app/[spaceId]/globals.css @@ -19,7 +19,7 @@ @apply gutter-stable; } h1 { - @apply tracking-[-0.025em] text-dark dark:text-light textwrap-balance; + @apply tracking-[-0.025em] text-dark dark:text-light text-balance; } h2, h3, @@ -101,12 +101,6 @@ .gutter-stable { scrollbar-gutter: stable; } - .textwrap-balance { - text-wrap: balance; - } - .textwrap-pretty { - text-wrap: pretty; - } .triangle { position: relative; diff --git a/src/components/Cookies/CookiesToast.tsx b/src/components/Cookies/CookiesToast.tsx index f21706a40..71be339f2 100644 --- a/src/components/Cookies/CookiesToast.tsx +++ b/src/components/Cookies/CookiesToast.tsx @@ -54,7 +54,7 @@ export function CookiesToast(props: { privacyPolicy?: string }) { 'right-4', 'left-16', 'max-w-md', - 'textwrap-balance', + 'text-balance', 'sm:left-auto', 'dark:ring-light/2', 'dark:bg-dark', diff --git a/src/components/DocumentView/Divider.tsx b/src/components/DocumentView/Divider.tsx index 14bde107a..8de0c6497 100644 --- a/src/components/DocumentView/Divider.tsx +++ b/src/components/DocumentView/Divider.tsx @@ -7,5 +7,5 @@ import { BlockProps } from './Block'; export function Divider(props: BlockProps) { const { style } = props; - return
; + return
; } diff --git a/src/components/DocumentView/Expandable/Expandable.tsx b/src/components/DocumentView/Expandable/Expandable.tsx index a0c102586..72ccde5c8 100644 --- a/src/components/DocumentView/Expandable/Expandable.tsx +++ b/src/components/DocumentView/Expandable/Expandable.tsx @@ -23,7 +23,7 @@ export function Expandable(props: BlockProps) {
) { 'border', 'border-b-0', 'border-light-3/8', - 'transition-color', //all '[&]:mt-[0px]', //select first child @@ -63,8 +62,10 @@ export function Expandable(props: BlockProps) { 'list-none', 'select-none', 'transition-colors', + 'group-hover/expandable:text-dark-5/7', 'group-open:text-dark-5/7', 'dark:group-open:text-light-5', + 'dark:group-hover/expandable:text-light-5', '[&::-webkit-details-marker]:hidden', )} > @@ -74,8 +75,9 @@ export function Expandable(props: BlockProps) { 'w-4', 'h-4', 'mr-2', + 'mb-1', + 'transition-transform', 'shrink-0', - 'transition-all', 'group-open:rotate-90', )} /> @@ -86,7 +88,7 @@ export function Expandable(props: BlockProps) { document={document} ancestorBlocks={[...ancestorBlocks, block]} context={context} - style={['px-10', 'pb-3', 'space-y-3']} + style={['px-10', 'pb-5', 'space-y-3']} />
); diff --git a/src/components/DocumentView/File.tsx b/src/components/DocumentView/File.tsx index 77f1dfc0c..eb9982bdd 100644 --- a/src/components/DocumentView/File.tsx +++ b/src/components/DocumentView/File.tsx @@ -1,4 +1,7 @@ import IconDownload from '@geist-ui/icons/download'; +import IconFileText from '@geist-ui/icons/fileText'; +import IconImage from '@geist-ui/icons/image'; +import IconPaperClip from '@geist-ui/icons/paperclip'; import { DocumentBlockFile } from '@gitbook/api'; import { getRevisionFile } from '@/lib/api'; @@ -16,31 +19,107 @@ export async function File(props: BlockProps) { return null; } + const contentType = (() => { + switch (file.contentType) { + case 'application/pdf': + case 'application/x-pdf': + return 'pdf'; + case 'image/png': + case 'image/jpeg': + case 'image/gif': + case 'image/webp': + case 'image/tiff': + case 'image/svg+xml': + return 'image'; + case 'application/zip': + case 'application/x-7z-compressed': + case 'application/x-zip-compressed': + case 'application/x-tar': + case 'application/x-rar-compressed': + case 'application/vnd.rar': + return 'archive'; + default: + return null; + } + })(); + + const icon = (() => { + switch (contentType) { + case 'pdf': + return ; + case 'image': + return ; + case 'archive': + return ; + default: + return ; + } + })(); + return ( -
- +
+
{icon}
+
+ {getHumanFileSize(file.size)} +
{file.name}
-
{getHumanFileSize(file.size)}
+
{contentType}
); diff --git a/src/components/DocumentView/Table/RecordColumnValue.tsx b/src/components/DocumentView/Table/RecordColumnValue.tsx index 851394633..b52dd9ae1 100644 --- a/src/components/DocumentView/Table/RecordColumnValue.tsx +++ b/src/components/DocumentView/Table/RecordColumnValue.tsx @@ -41,22 +41,40 @@ export async function RecordColumnValue( ); case 'rating': const rating = value as number; + const max = definition.max; return ( - + {value ? ( - - {Array.from({ length: rating }).map((_, i) => ( - - ))} - + <> + + {Array.from({ length: max }).map((_, i) => ( + + ))} + + + {Array.from({ length: rating }).map((_, i) => ( + + ))} + + ) : null} ); @@ -106,7 +124,7 @@ export async function RecordColumnValue( case 'content-ref': { const resolved = value ? await context.resolveContentRef(value as ContentRef) : null; return ( - + {resolved ? {resolved.text} : null} ); diff --git a/src/components/DocumentView/Table/RecordRow.tsx b/src/components/DocumentView/Table/RecordRow.tsx index dc97ff788..29d3d010f 100644 --- a/src/components/DocumentView/Table/RecordRow.tsx +++ b/src/components/DocumentView/Table/RecordRow.tsx @@ -33,7 +33,7 @@ export async function RecordRow( 'dark:border-light/2', )} > -
+
diff --git a/src/components/DocumentView/Table/ViewGrid.tsx b/src/components/DocumentView/Table/ViewGrid.tsx index 941cbf1fc..1cf2064c8 100644 --- a/src/components/DocumentView/Table/ViewGrid.tsx +++ b/src/components/DocumentView/Table/ViewGrid.tsx @@ -151,7 +151,7 @@ export function ViewGrid(props: TableViewProps) { className={tcls( tableTH, 'align-baseline', - 'textwrap-balance', + 'text-balance', 'border-b', 'border-b-dark/4', 'text-left', diff --git a/src/components/DocumentView/Tabs/DynamicTabs.tsx b/src/components/DocumentView/Tabs/DynamicTabs.tsx index e6d260ef7..fd4ca4fa2 100644 --- a/src/components/DocumentView/Tabs/DynamicTabs.tsx +++ b/src/components/DocumentView/Tabs/DynamicTabs.tsx @@ -31,7 +31,17 @@ export function DynamicTabs(props: { style, )} > -
+
{tabs.map((tab) => (
diff --git a/src/components/Header/HeaderLogo.tsx b/src/components/Header/HeaderLogo.tsx index d522841dd..71faabbad 100644 --- a/src/components/Header/HeaderLogo.tsx +++ b/src/components/Header/HeaderLogo.tsx @@ -1,4 +1,4 @@ -import { Collection, CustomizationSettings, Space } from '@gitbook/api'; +import { Collection, CustomizationHeaderPreset, CustomizationSettings, Space } from '@gitbook/api'; import Link from 'next/link'; import { HeaderMobileMenu } from '@/components/Header/HeaderMobileMenu'; @@ -17,12 +17,19 @@ interface HeaderLogoProps { /** * Render the logo for a space using the customization settings. */ + export function HeaderLogo(props: HeaderLogoProps) { const { customization } = props; - + const isCustomizationDefault = + customization.header.preset === CustomizationHeaderPreset.Default; return (
- +

1 ? ['ps-6', 'opacity-8'] : null, @@ -54,6 +53,7 @@ export function ScrollSectionsList(props: { sections: DocumentSection[] }) { 'border-primary', 'dark:text-primary-400', 'dark:border-primary-400', + 'opacity-[1]', ] : '', )} diff --git a/src/components/Search/SearchButton.tsx b/src/components/Search/SearchButton.tsx index 7d5230817..b536721b5 100644 --- a/src/components/Search/SearchButton.tsx +++ b/src/components/Search/SearchButton.tsx @@ -52,8 +52,10 @@ export function SearchButton(props: { children?: React.ReactNode; style?: ClassV 'dark:bg-light/1', 'dark:ring-light/1', 'dark:text-light/7', + '[&>p]:hidden', '[&>span]:hidden', 'md:justify-start', + 'md:[&>p]:flex', 'md:[&>span]:flex', 'md:w-full', 'md:px-3.5', diff --git a/src/components/TableOfContents/TableOfContents.tsx b/src/components/TableOfContents/TableOfContents.tsx index a3ab5da0d..07db75c92 100644 --- a/src/components/TableOfContents/TableOfContents.tsx +++ b/src/components/TableOfContents/TableOfContents.tsx @@ -68,7 +68,7 @@ export function TableOfContents(props: { {header ? header : null}