From eee30e2556e555affbd0f3034b4b2089352cea7c Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 13 Jun 2021 12:15:07 +0200 Subject: added selection component --- components/selection.tsx | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ pages/_app.tsx | 1 + styles/selection.css | 29 ++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 components/selection.tsx create mode 100644 styles/selection.css diff --git a/components/selection.tsx b/components/selection.tsx new file mode 100644 index 0000000..4a0812f --- /dev/null +++ b/components/selection.tsx @@ -0,0 +1,89 @@ +import { CSSProperties } from 'react'; +import { slideTypes } from '../timeline'; + +type cornerTypes = 'round' | 'diamond' | 'square' | 'square-s'; +var slideTypeToCornerType = { + default: 'diamond', + loop: 'square', + speedChange: 'square', + delay: 'round', +}; + +function Corner(props: { + type: cornerTypes; + direction: 'tl' | 'tr' | 'bl' | 'br'; +}) { + var className = 'corner posabs ' + props.direction + ' '; + + if (props.direction[0] == 't') className += 't0 '; + if (props.direction[0] == 'b') className += 'b0 '; + if (props.direction[1] == 'l') className += 'l0 '; + if (props.direction[1] == 'r') className += 'r0 '; + + var style: CSSProperties = { transform: '' }; + if (props.direction[0] == 'b') style.transform += 'scaleY(-1) '; + if (props.direction[1] == 'l') style.transform += 'scaleX(-1) '; + + if (props.type == 'square-s') { + className += 'small '; + return + + ; + } + + return + {{ + 'round': , + 'diamond': , + 'square': , + }[props.type]} + ; +} + +export default function Selection(props: { + width: number; + height: number; + left?: slideTypes; + right?: slideTypes; +}) { + var small = props.width < 24 || props.height < 24; + return
+
+
+
+
+ + + + +
; +} diff --git a/pages/_app.tsx b/pages/_app.tsx index 96182ab..9dc0a1e 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -7,6 +7,7 @@ import '../styles/globals.css'; import '../styles/keyframes.css'; import '../styles/paper.css'; import '../styles/presentation.css'; +import '../styles/selection.css'; import '../styles/util.css'; export default function Blog({ Component, pageProps }) { diff --git a/styles/selection.css b/styles/selection.css new file mode 100644 index 0000000..6bcbd88 --- /dev/null +++ b/styles/selection.css @@ -0,0 +1,29 @@ +.selection { + --selection-color: var(--gruble); + --corner-size: 12px; + filter: drop-shadow(0px 0px 10px var(--selection-color)); +} + +.selection .bar.top, +.selection .bar.bottom { + height: 2px; + + left: var(--corner-size); + right: var(--corner-size); +} + +.selection .bar.left, +.selection .bar.right { + width: 2px; + + top: var(--corner-size); + bottom: var(--corner-size); +} + +.selection .bar { + background-color: var(--selection-color); +} + +.selection .corner { + fill: var(--selection-color); +} -- cgit v1.2.3