From 7573ae709ee1a0b92701956c5dc2cfeecdfd3e60 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Tue, 1 Nov 2022 10:26:52 +0200 Subject: [PATCH] styles: run prettier --- .../ContextBar/contextBarActionFactory.tsx | 19 +++++++- .../src/components/inputs/ColorInput.tsx | 47 ++++++++++--------- tldraw/apps/tldraw-logseq/src/lib/color.ts | 2 +- .../tldraw-logseq/src/lib/shapes/BoxShape.tsx | 4 +- .../src/lib/shapes/EllipseShape.tsx | 8 ++-- .../src/lib/shapes/HighlighterShape.tsx | 2 +- .../src/lib/shapes/LineShape.tsx | 8 ++-- .../src/lib/shapes/LogseqPortalShape.tsx | 23 +++++++-- .../tldraw-logseq/src/lib/shapes/PenShape.tsx | 4 +- .../src/lib/shapes/PencilShape.tsx | 4 +- .../src/lib/shapes/PolygonShape.tsx | 8 ++-- .../src/lib/shapes/TextShape.tsx | 4 +- 12 files changed, 83 insertions(+), 50 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx index 4cde1ee84f..4f23b6b2ac 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx @@ -57,7 +57,14 @@ const contextBarActionMapping = new Map() type ShapeType = Shape['props']['type'] export const shapeMapping: Partial> = { - 'logseq-portal': ['Swatch', 'Edit', 'LogseqPortalViewMode', 'ScaleLevel', 'OpenPage', 'AutoResizing'], + 'logseq-portal': [ + 'Swatch', + 'Edit', + 'LogseqPortalViewMode', + 'ScaleLevel', + 'OpenPage', + 'AutoResizing', + ], youtube: ['YoutubeLink'], iframe: ['IFrameSource'], box: ['Swatch', 'NoFill', 'StrokeType'], @@ -346,7 +353,15 @@ const SwatchAction = observer(() => { }, []) const color = shapes[0].props.noFill ? shapes[0].props.stroke : shapes[0].props.fill - return + return ( + + ) }) const StrokeTypeAction = observer(() => { diff --git a/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx b/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx index 87d178253d..fbfa61204f 100644 --- a/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx @@ -1,6 +1,6 @@ import * as React from 'react' -import * as Popover from '@radix-ui/react-popover'; -import * as Slider from '@radix-ui/react-slider'; +import * as Popover from '@radix-ui/react-popover' +import * as Slider from '@radix-ui/react-slider' import { TablerIcon } from '../icons' import { Color } from '@tldraw/core' interface ColorInputProps extends React.InputHTMLAttributes { @@ -14,41 +14,45 @@ export function ColorInput({ color, opacity, setColor, setOpacity, ...rest }: Co const ref = React.useRef(null) function renderColor(color: string) { - return color ? -
+ return color ? ( +
-
: -
+
+ ) : ( +
+ +
+ ) } return ( - - + - -
- {Object.values(Color).map(value => + +
+ {Object.values(Color).map(value => ( - )} + ))}
- setOpacity(value[0])} max={1} step={0.1} aria-label="Opacity" className="tl-slider-root"> + setOpacity(value[0])} + max={1} + step={0.1} + aria-label="Opacity" + className="tl-slider-root" + > @@ -57,7 +61,6 @@ export function ColorInput({ color, opacity, setColor, setOpacity, ...rest }: Co
-
diff --git a/tldraw/apps/tldraw-logseq/src/lib/color.ts b/tldraw/apps/tldraw-logseq/src/lib/color.ts index cde6a32e23..04d76e8536 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/color.ts +++ b/tldraw/apps/tldraw-logseq/src/lib/color.ts @@ -16,7 +16,7 @@ function getMeasurementDiv() { export function getComputedColor(color: string, type: string): string { if (Object.values(Color).includes(color)) { - return `var(--ls-wb-${type}-color-${color ? color : "default"})`; + return `var(--ls-wb-${type}-color-${color ? color : 'default'})` } return color diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/BoxShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/BoxShape.tsx index bbb5d83880..1d1a4bfe7a 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/BoxShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/BoxShape.tsx @@ -64,9 +64,9 @@ export class BoxShape extends TLBoxShape { width={Math.max(0.01, w - strokeWidth)} height={Math.max(0.01, h - strokeWidth)} strokeWidth={strokeWidth} - stroke={getComputedColor(stroke, "stroke")} + stroke={getComputedColor(stroke, 'stroke')} strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined} - fill={noFill ? 'none' : getComputedColor(fill, "background")} + fill={noFill ? 'none' : getComputedColor(fill, 'background')} /> ) diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx index de1dc14640..33c1a99b89 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx @@ -52,9 +52,9 @@ export class EllipseShape extends TLEllipseShape { rx={Math.max(0.01, (w - strokeWidth) / 2)} ry={Math.max(0.01, (h - strokeWidth) / 2)} strokeWidth={strokeWidth} - stroke={getComputedColor(stroke, "stroke")} + stroke={getComputedColor(stroke, 'stroke')} strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined} - fill={noFill ? 'none' : getComputedColor(fill, "background")} + fill={noFill ? 'none' : getComputedColor(fill, 'background')} /> ) @@ -106,9 +106,9 @@ export class EllipseShape extends TLEllipseShape { rx={Math.max(0.01, (w - strokeWidth) / 2)} ry={Math.max(0.01, (h - strokeWidth) / 2)} strokeWidth={strokeWidth} - stroke={getComputedColor(stroke, "stroke")} + stroke={getComputedColor(stroke, 'stroke')} strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined} - fill={noFill ? 'none' : getComputedColor(fill, "background")} + fill={noFill ? 'none' : getComputedColor(fill, 'background')} /> ) diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/HighlighterShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/HighlighterShape.tsx index 4cc5a6e48c..7e488cf706 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/HighlighterShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/HighlighterShape.tsx @@ -49,7 +49,7 @@ export class HighlighterShape extends TLDrawShape { { { <> { fontSize={20} transform={`translate(${midPoint[0]}, ${midPoint[1]})`} textAnchor="middle" - fill={getComputedColor(stroke, "text")} - stroke={getComputedColor(stroke, "text")} + fill={getComputedColor(stroke, 'text')} + stroke={getComputedColor(stroke, 'text')} > {label} diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx index 15cc4c958d..27e0bb5d1d 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx @@ -73,10 +73,25 @@ const LogseqTypeTag = ({ const LogseqPortalShapeHeader = observer( ({ type, fill, children }: { type: 'P' | 'B'; fill: string; children: React.ReactNode }) => { - const bgColor = getComputedColor(fill, "background"); + const bgColor = getComputedColor(fill, 'background') - return
{children}
+ return ( +
+ {children} +
+ ) } ) @@ -711,7 +726,7 @@ export class LogseqPortalShape extends TLBoxShape { ref={cpRefContainer} className="tl-logseq-cp-container" style={{ - background: fill ? `var(--ls-highlight-color-${fill})` : "transparent", + background: fill ? `var(--ls-highlight-color-${fill})` : 'transparent', overflow: this.props.isAutoResizing ? 'visible' : 'auto', }} > diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/PenShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/PenShape.tsx index bf0f86428d..adebd84e6f 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/PenShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/PenShape.tsx @@ -57,8 +57,8 @@ export class PenShape extends TLDrawShape { diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/PencilShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/PencilShape.tsx index a6d86adc62..29cc9aaa0d 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/PencilShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/PencilShape.tsx @@ -132,8 +132,8 @@ export class PencilShape extends TLDrawShape { strokeWidth={strokeWidth / 2} strokeLinejoin="round" strokeLinecap="round" - stroke={getComputedColor(stroke, "stroke")} - fill={getComputedColor(stroke, "stroke")} + stroke={getComputedColor(stroke, 'stroke')} + fill={getComputedColor(stroke, 'stroke')} strokeDasharray={strokeType === 'dashed' ? '12 4' : undefined} /> ) diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/PolygonShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/PolygonShape.tsx index 8a303f4cf8..ab9dc1d734 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/PolygonShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/PolygonShape.tsx @@ -44,8 +44,8 @@ export class PolygonShape extends TLPolygonShape { /> { { fontWeight, padding, lineHeight, - color: getComputedColor(stroke, "text"), + color: getComputedColor(stroke, 'text'), }} > {isEditing ? ( @@ -320,7 +320,7 @@ export class TextShape extends TLTextShape {