Remove topBar prop from <TldrawUi /> (#2018)

This diff removes the UI top center bar from the public API and tweaks
some of the styling around the top bar as a whole. Now, the left and
right bars shrink to fit their content, and the center bar is unstyled
by us. It's also marked `@internal`.

This also exposes `<Spinner />` for internal use.

### Change Type

- [x] `minor` — New feature

### Test Plan

-

### Release Notes

- [BREAKING] removed topBar prop
This commit is contained in:
alex 2023-10-09 07:02:43 +01:00 committed by GitHub
parent edf79e56c0
commit 37f8a7a491
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 33 deletions

View file

@ -4,7 +4,7 @@ import '@tldraw/tldraw/tldraw.css'
export default function Example() { export default function Example() {
return ( return (
<div className="tldraw__editor"> <div className="tldraw__editor">
<Tldraw shareZone={<CustomShareZone />} topZone={<CustomTopZone />} /> <Tldraw shareZone={<CustomShareZone />} />
</div> </div>
) )
} }
@ -23,17 +23,3 @@ function CustomShareZone() {
</div> </div>
) )
} }
function CustomTopZone() {
return (
<div
style={{
width: '100%',
backgroundColor: 'dodgerblue',
textAlign: 'center',
}}
>
<p>Top Zone</p>
</div>
)
}

View file

@ -1051,6 +1051,9 @@ export function setDefaultEditorAssetUrls(assetUrls: TLEditorAssetUrls): void;
// @internal (undocumented) // @internal (undocumented)
export function setDefaultUiAssetUrls(urls: TLUiAssetUrls): void; export function setDefaultUiAssetUrls(urls: TLUiAssetUrls): void;
// @internal (undocumented)
export function Spinner(props: React_2.SVGProps<SVGSVGElement>): JSX.Element;
// @public (undocumented) // @public (undocumented)
function Sub({ id, children }: { function Sub({ id, children }: {
id: string; id: string;
@ -1230,6 +1233,7 @@ export interface TldrawUiBaseProps {
hideUi?: boolean; hideUi?: boolean;
renderDebugMenuItems?: () => React_2.ReactNode; renderDebugMenuItems?: () => React_2.ReactNode;
shareZone?: ReactNode; shareZone?: ReactNode;
// @internal
topZone?: ReactNode; topZone?: ReactNode;
} }

View file

@ -41,6 +41,7 @@ export {
} from './lib/ui/TldrawUiContextProvider' } from './lib/ui/TldrawUiContextProvider'
export { setDefaultUiAssetUrls } from './lib/ui/assetUrls' export { setDefaultUiAssetUrls } from './lib/ui/assetUrls'
export { ContextMenu, type TLUiContextMenuProps } from './lib/ui/components/ContextMenu' export { ContextMenu, type TLUiContextMenuProps } from './lib/ui/components/ContextMenu'
export { Spinner } from './lib/ui/components/Spinner'
export { Button, type TLUiButtonProps } from './lib/ui/components/primitives/Button' export { Button, type TLUiButtonProps } from './lib/ui/components/primitives/Button'
export { Icon, type TLUiIconProps } from './lib/ui/components/primitives/Icon' export { Icon, type TLUiIconProps } from './lib/ui/components/primitives/Icon'
export { Input, type TLUiInputProps } from './lib/ui/components/primitives/Input' export { Input, type TLUiInputProps } from './lib/ui/components/primitives/Input'

View file

@ -33,6 +33,7 @@
grid-row: 1; grid-row: 1;
display: flex; display: flex;
min-width: 0px; min-width: 0px;
justify-content: space-between;
} }
.tlui-layout__top__left { .tlui-layout__top__left {
@ -42,19 +43,7 @@
justify-content: flex-start; justify-content: flex-start;
width: 100%; width: 100%;
height: 100%; height: 100%;
flex-shrink: 1; flex: 0 1 0;
}
.tlui-layout__top__center {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
width: 100%;
height: 100%;
margin-left: var(--space-2);
flex-grow: 1;
min-width: 0px;
} }
.tlui-layout__top__right { .tlui-layout__top__right {
@ -62,9 +51,8 @@
flex-direction: column; flex-direction: column;
align-items: flex-end; align-items: flex-end;
justify-content: flex-start; justify-content: flex-start;
width: 100%;
height: 100%; height: 100%;
flex-shrink: 1; flex: 0 0 auto;
min-width: 0px; min-width: 0px;
} }
@ -1272,7 +1260,7 @@
.tlui-toast__content { .tlui-toast__content {
padding-left: 0px; padding-left: 0px;
padding-top: var(--space-4); padding-top: var(--space-4);
padding-bottom: var(--space-5); padding-bottom: var(--space-4);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: var(--space-3); gap: var(--space-3);

View file

@ -53,6 +53,7 @@ export interface TldrawUiBaseProps {
/** /**
* A component to use for the top zone (will be deprecated) * A component to use for the top zone (will be deprecated)
* @internal
*/ */
topZone?: ReactNode topZone?: ReactNode

View file

@ -1,5 +1,6 @@
import React from 'react' import React from 'react'
/** @internal */
export function Spinner(props: React.SVGProps<SVGSVGElement>) { export function Spinner(props: React.SVGProps<SVGSVGElement>) {
return ( return (
<svg width={16} height={16} viewBox="0 0 16 16" {...props}> <svg width={16} height={16} viewBox="0 0 16 16" {...props}>

View file

@ -31,8 +31,10 @@ function Toast({ toast }: { toast: TLUiToast }) {
)} )}
<div className="tlui-toast__main"> <div className="tlui-toast__main">
<div className="tlui-toast__content"> <div className="tlui-toast__content">
<T.Title className="tlui-toast__title">{toast.title}</T.Title> {toast.title && <T.Title className="tlui-toast__title">{toast.title}</T.Title>}
<T.Description className="tlui-toast__description">{toast.description}</T.Description> {toast.description && (
<T.Description className="tlui-toast__description">{toast.description}</T.Description>
)}
</div> </div>
{toast.actions && ( {toast.actions && (
<div className="tlui-toast__actions"> <div className="tlui-toast__actions">