浏览代码

styles: run prettier

Konstantinos Kaloutas 3 年之前
父节点
当前提交
7573ae709e

+ 17 - 2
tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx

@@ -57,7 +57,14 @@ const contextBarActionMapping = new Map<ContextBarActionType, React.FC>()
 type ShapeType = Shape['props']['type']
 type ShapeType = Shape['props']['type']
 
 
 export const shapeMapping: Partial<Record<ShapeType, ContextBarActionType[]>> = {
 export const shapeMapping: Partial<Record<ShapeType, ContextBarActionType[]>> = {
-  'logseq-portal': ['Swatch', 'Edit', 'LogseqPortalViewMode', 'ScaleLevel', 'OpenPage', 'AutoResizing'],
+  'logseq-portal': [
+    'Swatch',
+    'Edit',
+    'LogseqPortalViewMode',
+    'ScaleLevel',
+    'OpenPage',
+    'AutoResizing',
+  ],
   youtube: ['YoutubeLink'],
   youtube: ['YoutubeLink'],
   iframe: ['IFrameSource'],
   iframe: ['IFrameSource'],
   box: ['Swatch', 'NoFill', 'StrokeType'],
   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
   const color = shapes[0].props.noFill ? shapes[0].props.stroke : shapes[0].props.fill
-  return <ColorInput title="Color Picker" color={color} opacity={shapes[0].props.opacity} setOpacity={handleSetOpacity} setColor={handleSetColor} />
+  return (
+    <ColorInput
+      title="Color Picker"
+      color={color}
+      opacity={shapes[0].props.opacity}
+      setOpacity={handleSetOpacity}
+      setColor={handleSetColor}
+    />
+  )
 })
 })
 
 
 const StrokeTypeAction = observer(() => {
 const StrokeTypeAction = observer(() => {

+ 25 - 22
tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx

@@ -1,6 +1,6 @@
 import * as React from 'react'
 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 { TablerIcon } from '../icons'
 import { Color } from '@tldraw/core'
 import { Color } from '@tldraw/core'
 interface ColorInputProps extends React.InputHTMLAttributes<HTMLButtonElement> {
 interface ColorInputProps extends React.InputHTMLAttributes<HTMLButtonElement> {
@@ -14,41 +14,45 @@ export function ColorInput({ color, opacity, setColor, setOpacity, ...rest }: Co
   const ref = React.useRef<HTMLDivElement>(null)
   const ref = React.useRef<HTMLDivElement>(null)
 
 
   function renderColor(color: string) {
   function renderColor(color: string) {
-    return color ?
-      <div className="tl-color-bg" style={{backgroundColor: color}}>
+    return color ? (
+      <div className="tl-color-bg" style={{ backgroundColor: color }}>
         <div className={`w-full h-full bg-${color}-500`}></div>
         <div className={`w-full h-full bg-${color}-500`}></div>
-      </div> :
-      <div className={"tl-color-bg"}><TablerIcon name="color-swatch" /></div>
+      </div>
+    ) : (
+      <div className={'tl-color-bg'}>
+        <TablerIcon name="color-swatch" />
+      </div>
+    )
   }
   }
 
 
   return (
   return (
     <Popover.Root>
     <Popover.Root>
-
       <Popover.Trigger>
       <Popover.Trigger>
-        <button className="tl-color-drip mx-1">
-          {renderColor(color)}
-        </button>
+        <button className="tl-color-drip mx-1">{renderColor(color)}</button>
       </Popover.Trigger>
       </Popover.Trigger>
 
 
       <Popover.Portal>
       <Popover.Portal>
-        <Popover.Content
-          className="tl-popover-content"
-          side="top"
-          sideOffset={15}
-        >
-          <div className={"tl-color-palette"}>
-            {Object.values(Color).map(value =>
+        <Popover.Content className="tl-popover-content" side="top" sideOffset={15}>
+          <div className={'tl-color-palette'}>
+            {Object.values(Color).map(value => (
               <button
               <button
-                className={`tl-color-drip m-1${value === color ? " active" : ""}`}
-                onClick={()=>setColor(value)}
+                className={`tl-color-drip m-1${value === color ? ' active' : ''}`}
+                onClick={() => setColor(value)}
               >
               >
                 {renderColor(value)}
                 {renderColor(value)}
               </button>
               </button>
-            )}
+            ))}
           </div>
           </div>
 
 
           <div className="m-1">
           <div className="m-1">
-            <Slider.Root defaultValue={[opacity]} onValueCommit={(value)=>setOpacity(value[0])} max={1} step={0.1} aria-label="Opacity" className="tl-slider-root">
+            <Slider.Root
+              defaultValue={[opacity]}
+              onValueCommit={value => setOpacity(value[0])}
+              max={1}
+              step={0.1}
+              aria-label="Opacity"
+              className="tl-slider-root"
+            >
               <Slider.Track className="tl-slider-track">
               <Slider.Track className="tl-slider-track">
                 <Slider.Range className="tl-slider-range" />
                 <Slider.Range className="tl-slider-range" />
               </Slider.Track>
               </Slider.Track>
@@ -57,7 +61,6 @@ export function ColorInput({ color, opacity, setColor, setOpacity, ...rest }: Co
           </div>
           </div>
 
 
           <Popover.Arrow className="tl-popover-arrow" />
           <Popover.Arrow className="tl-popover-arrow" />
-
         </Popover.Content>
         </Popover.Content>
       </Popover.Portal>
       </Popover.Portal>
     </Popover.Root>
     </Popover.Root>

+ 1 - 1
tldraw/apps/tldraw-logseq/src/lib/color.ts

@@ -16,7 +16,7 @@ function getMeasurementDiv() {
 
 
 export function getComputedColor(color: string, type: string): string {
 export function getComputedColor(color: string, type: string): string {
   if (Object.values(Color).includes(color)) {
   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
   return color

+ 2 - 2
tldraw/apps/tldraw-logseq/src/lib/shapes/BoxShape.tsx

@@ -64,9 +64,9 @@ export class BoxShape extends TLBoxShape<BoxShapeProps> {
           width={Math.max(0.01, w - strokeWidth)}
           width={Math.max(0.01, w - strokeWidth)}
           height={Math.max(0.01, h - strokeWidth)}
           height={Math.max(0.01, h - strokeWidth)}
           strokeWidth={strokeWidth}
           strokeWidth={strokeWidth}
-          stroke={getComputedColor(stroke, "stroke")}
+          stroke={getComputedColor(stroke, 'stroke')}
           strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined}
           strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined}
-          fill={noFill ? 'none' : getComputedColor(fill, "background")}
+          fill={noFill ? 'none' : getComputedColor(fill, 'background')}
         />
         />
       </SVGContainer>
       </SVGContainer>
     )
     )

+ 4 - 4
tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx

@@ -52,9 +52,9 @@ export class EllipseShape extends TLEllipseShape<EllipseShapeProps> {
           rx={Math.max(0.01, (w - strokeWidth) / 2)}
           rx={Math.max(0.01, (w - strokeWidth) / 2)}
           ry={Math.max(0.01, (h - strokeWidth) / 2)}
           ry={Math.max(0.01, (h - strokeWidth) / 2)}
           strokeWidth={strokeWidth}
           strokeWidth={strokeWidth}
-          stroke={getComputedColor(stroke, "stroke")}
+          stroke={getComputedColor(stroke, 'stroke')}
           strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined}
           strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined}
-          fill={noFill ? 'none' : getComputedColor(fill, "background")}
+          fill={noFill ? 'none' : getComputedColor(fill, 'background')}
         />
         />
       </SVGContainer>
       </SVGContainer>
     )
     )
@@ -106,9 +106,9 @@ export class EllipseShape extends TLEllipseShape<EllipseShapeProps> {
           rx={Math.max(0.01, (w - strokeWidth) / 2)}
           rx={Math.max(0.01, (w - strokeWidth) / 2)}
           ry={Math.max(0.01, (h - strokeWidth) / 2)}
           ry={Math.max(0.01, (h - strokeWidth) / 2)}
           strokeWidth={strokeWidth}
           strokeWidth={strokeWidth}
-          stroke={getComputedColor(stroke, "stroke")}
+          stroke={getComputedColor(stroke, 'stroke')}
           strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined}
           strokeDasharray={strokeType === 'dashed' ? '8 2' : undefined}
-          fill={noFill ? 'none' : getComputedColor(fill, "background")}
+          fill={noFill ? 'none' : getComputedColor(fill, 'background')}
         />
         />
       </g>
       </g>
     )
     )

+ 1 - 1
tldraw/apps/tldraw-logseq/src/lib/shapes/HighlighterShape.tsx

@@ -49,7 +49,7 @@ export class HighlighterShape extends TLDrawShape<HighlighterShapeProps> {
         <path
         <path
           d={pointsPath}
           d={pointsPath}
           strokeWidth={strokeWidth * 16}
           strokeWidth={strokeWidth * 16}
-          stroke={getComputedColor(stroke, "stroke")}
+          stroke={getComputedColor(stroke, 'stroke')}
           fill="none"
           fill="none"
           pointerEvents="all"
           pointerEvents="all"
           strokeLinejoin="round"
           strokeLinejoin="round"

+ 4 - 4
tldraw/apps/tldraw-logseq/src/lib/shapes/LineShape.tsx

@@ -77,7 +77,7 @@ export class LineShape extends TLLineShape<LineShapeProps> {
         <TextLabel
         <TextLabel
           font={font}
           font={font}
           text={label}
           text={label}
-          color={getComputedColor(stroke, "text")}
+          color={getComputedColor(stroke, 'text')}
           offsetX={offset[0]}
           offsetX={offset[0]}
           offsetY={offset[1]}
           offsetY={offset[1]}
           scale={scale}
           scale={scale}
@@ -162,7 +162,7 @@ export class LineShape extends TLLineShape<LineShapeProps> {
       <>
       <>
         <Arrow
         <Arrow
           style={{
           style={{
-            stroke: getComputedColor(stroke, "stroke"),
+            stroke: getComputedColor(stroke, 'stroke'),
             fill,
             fill,
             strokeWidth,
             strokeWidth,
             strokeType,
             strokeType,
@@ -182,8 +182,8 @@ export class LineShape extends TLLineShape<LineShapeProps> {
               fontSize={20}
               fontSize={20}
               transform={`translate(${midPoint[0]}, ${midPoint[1]})`}
               transform={`translate(${midPoint[0]}, ${midPoint[1]})`}
               textAnchor="middle"
               textAnchor="middle"
-              fill={getComputedColor(stroke, "text")}
-              stroke={getComputedColor(stroke, "text")}
+              fill={getComputedColor(stroke, 'text')}
+              stroke={getComputedColor(stroke, 'text')}
             >
             >
               {label}
               {label}
             </text>
             </text>

+ 19 - 4
tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx

@@ -73,10 +73,25 @@ const LogseqTypeTag = ({
 
 
 const LogseqPortalShapeHeader = observer(
 const LogseqPortalShapeHeader = observer(
   ({ type, fill, children }: { type: 'P' | 'B'; fill: string; children: React.ReactNode }) => {
   ({ type, fill, children }: { type: 'P' | 'B'; fill: string; children: React.ReactNode }) => {
-    const bgColor = getComputedColor(fill, "background");
+    const bgColor = getComputedColor(fill, 'background')
 
 
-    return <div className={`tl-logseq-portal-header tl-logseq-portal-header-${type === "P" ? "page" : "block"}`}
-      style={{background: type === "P" ? bgColor : `linear-gradient(0deg, var(--ls-highlight-color-${fill ? fill : "default"}), ${bgColor}`}}>{children}</div>
+    return (
+      <div
+        className={`tl-logseq-portal-header tl-logseq-portal-header-${
+          type === 'P' ? 'page' : 'block'
+        }`}
+        style={{
+          background:
+            type === 'P'
+              ? bgColor
+              : `linear-gradient(0deg, var(--ls-highlight-color-${
+                  fill ? fill : 'default'
+                }), ${bgColor}`,
+        }}
+      >
+        {children}
+      </div>
+    )
   }
   }
 )
 )
 
 
@@ -711,7 +726,7 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
         ref={cpRefContainer}
         ref={cpRefContainer}
         className="tl-logseq-cp-container"
         className="tl-logseq-cp-container"
         style={{
         style={{
-          background: fill ? `var(--ls-highlight-color-${fill})` : "transparent",
+          background: fill ? `var(--ls-highlight-color-${fill})` : 'transparent',
           overflow: this.props.isAutoResizing ? 'visible' : 'auto',
           overflow: this.props.isAutoResizing ? 'visible' : 'auto',
         }}
         }}
       >
       >

+ 2 - 2
tldraw/apps/tldraw-logseq/src/lib/shapes/PenShape.tsx

@@ -57,8 +57,8 @@ export class PenShape extends TLDrawShape<PenShapeProps> {
         <path
         <path
           d={pointsPath}
           d={pointsPath}
           strokeWidth={strokeWidth}
           strokeWidth={strokeWidth}
-          stroke={getComputedColor(stroke, "stroke")}
-          fill={getComputedColor(stroke, "stroke")}
+          stroke={getComputedColor(stroke, 'stroke')}
+          fill={getComputedColor(stroke, 'stroke')}
           pointerEvents="all"
           pointerEvents="all"
         />
         />
       </SVGContainer>
       </SVGContainer>

+ 2 - 2
tldraw/apps/tldraw-logseq/src/lib/shapes/PencilShape.tsx

@@ -132,8 +132,8 @@ export class PencilShape extends TLDrawShape<PencilShapeProps> {
         strokeWidth={strokeWidth / 2}
         strokeWidth={strokeWidth / 2}
         strokeLinejoin="round"
         strokeLinejoin="round"
         strokeLinecap="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}
         strokeDasharray={strokeType === 'dashed' ? '12 4' : undefined}
       />
       />
     )
     )

+ 4 - 4
tldraw/apps/tldraw-logseq/src/lib/shapes/PolygonShape.tsx

@@ -44,8 +44,8 @@ export class PolygonShape extends TLPolygonShape<PolygonShapeProps> {
           />
           />
           <polygon
           <polygon
             points={path}
             points={path}
-            stroke={getComputedColor(stroke, "stroke")}
-            fill={noFill ? 'none' : getComputedColor(fill, "background")}
+            stroke={getComputedColor(stroke, 'stroke')}
+            fill={noFill ? 'none' : getComputedColor(fill, 'background')}
             strokeWidth={strokeWidth}
             strokeWidth={strokeWidth}
             rx={2}
             rx={2}
             ry={2}
             ry={2}
@@ -92,8 +92,8 @@ export class PolygonShape extends TLPolygonShape<PolygonShapeProps> {
         <polygon className={!noFill ? 'tl-hitarea-fill' : 'tl-hitarea-stroke'} points={path} />
         <polygon className={!noFill ? 'tl-hitarea-fill' : 'tl-hitarea-stroke'} points={path} />
         <polygon
         <polygon
           points={path}
           points={path}
-          stroke={getComputedColor(stroke, "stroke")}
-          fill={noFill ? 'none' : getComputedColor(fill, "background")}
+          stroke={getComputedColor(stroke, 'stroke')}
+          fill={noFill ? 'none' : getComputedColor(fill, 'background')}
           strokeWidth={strokeWidth}
           strokeWidth={strokeWidth}
           rx={2}
           rx={2}
           ry={2}
           ry={2}

+ 2 - 2
tldraw/apps/tldraw-logseq/src/lib/shapes/TextShape.tsx

@@ -193,7 +193,7 @@ export class TextShape extends TLTextShape<TextShapeProps> {
             fontWeight,
             fontWeight,
             padding,
             padding,
             lineHeight,
             lineHeight,
-            color: getComputedColor(stroke, "text"),
+            color: getComputedColor(stroke, 'text'),
           }}
           }}
         >
         >
           {isEditing ? (
           {isEditing ? (
@@ -320,7 +320,7 @@ export class TextShape extends TLTextShape<TextShapeProps> {
       <foreignObject width={bounds.width} height={bounds.height}>
       <foreignObject width={bounds.width} height={bounds.height}>
         <div
         <div
           style={{
           style={{
-            color: getComputedColor(stroke, "text"),
+            color: getComputedColor(stroke, 'text'),
             fontSize,
             fontSize,
             fontFamily,
             fontFamily,
           }}
           }}