From 14b506bff0be08f5f2ff13ab0d438a65398357dc Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Wed, 1 Jun 2022 08:42:27 +0000 Subject: [PATCH] chore: add tab-bar --- package.json | 8 +- packages/core/package.json | 2 +- pnpm-lock.yaml | 58 ++--- src/components/EditorSection/DragHandle.tsx | 72 ++++++ src/components/EditorSection/Editor.astro | 10 + .../EditorSection/EditorSection.astro | 210 +++++++++--------- src/components/EditorSection/Tabs.astro | 47 ++++ src/components/Footer.astro | 8 +- src/components/SearchSection/Result.tsx | 6 +- .../SearchSection/SearchContainer.tsx | 26 ++- .../SearchSection/SearchResults.tsx | 12 +- src/pages/index.astro | 2 + src/styles/base.scss | 2 + src/styles/components/_search.scss | 24 +- 14 files changed, 314 insertions(+), 173 deletions(-) create mode 100644 src/components/EditorSection/DragHandle.tsx create mode 100644 src/components/EditorSection/Tabs.astro diff --git a/package.json b/package.json index ef2393b..84d85bf 100644 --- a/package.json +++ b/package.json @@ -71,8 +71,8 @@ "@astrojs/sitemap": "^0.1.0", "@astrojs/solid-js": "^0.1.3", "@astrojs/tailwind": "^0.2.1", - "@commitlint/cli": "^17.0.1", - "@commitlint/config-conventional": "^17.0.0", + "@commitlint/cli": "^17.0.2", + "@commitlint/config-conventional": "^17.0.2", "@iconify/json": "^2.1.54", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", @@ -98,7 +98,7 @@ "solid-js": "^1.4.3", "tiny-glob": "^0.2.9", "tsm": "^2.2.1", - "typedoc": "^0.22.16", + "typedoc": "^0.22.17", "typedoc-plugin-extras": "^2.2.3", "typedoc-plugin-mdn-links": "^1.0.6", "typedoc-plugin-missing-exports": "^0.22.6", @@ -106,6 +106,6 @@ "unified": "^10.1.2", "unplugin-auto-import": "^0.8.6", "unplugin-icons": "^0.14.3", - "vitest": "^0.13.0" + "vitest": "^0.13.1" } } diff --git a/packages/core/package.json b/packages/core/package.json index 7f3a9f3..eee1116 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -88,6 +88,6 @@ "typescript-json-schema": "^0.53.1", "vite": "^2.9.9", "vite-plugin-dts": "^1.2.0", - "vitest": "^0.13.0" + "vitest": "^0.13.1" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c97bc07..0a0d1d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,8 +8,8 @@ importers: '@astrojs/solid-js': ^0.1.3 '@astrojs/tailwind': ^0.2.1 '@bundlejs/core': workspace:^0.0.0 - '@commitlint/cli': ^17.0.1 - '@commitlint/config-conventional': ^17.0.0 + '@commitlint/cli': ^17.0.2 + '@commitlint/config-conventional': ^17.0.2 '@dprint/formatter': ^0.2.0 '@iconify/json': ^2.1.54 '@okikio/animate': ^2.3.1 @@ -43,7 +43,7 @@ importers: solid-js: ^1.4.3 tiny-glob: ^0.2.9 tsm: ^2.2.1 - typedoc: ^0.22.16 + typedoc: ^0.22.17 typedoc-plugin-extras: ^2.2.3 typedoc-plugin-mdn-links: ^1.0.6 typedoc-plugin-missing-exports: ^0.22.6 @@ -52,7 +52,7 @@ importers: unified: ^10.1.2 unplugin-auto-import: ^0.8.6 unplugin-icons: ^0.14.3 - vitest: ^0.13.0 + vitest: ^0.13.1 workbox-window: ^6.5.3 dependencies: '@bundlejs/core': link:packages/core @@ -70,8 +70,8 @@ importers: '@astrojs/sitemap': 0.1.0 '@astrojs/solid-js': 0.1.3_solid-js@1.4.3 '@astrojs/tailwind': 0.2.1 - '@commitlint/cli': 17.0.1 - '@commitlint/config-conventional': 17.0.0 + '@commitlint/cli': 17.0.2 + '@commitlint/config-conventional': 17.0.2 '@iconify/json': 2.1.54 '@semantic-release/changelog': 6.0.1_semantic-release@19.0.2 '@semantic-release/git': 10.0.1_semantic-release@19.0.2 @@ -105,7 +105,7 @@ importers: unified: 10.1.2 unplugin-auto-import: 0.8.6 unplugin-icons: 0.14.3 - vitest: 0.13.0_sass@1.52.1 + vitest: 0.13.1_sass@1.52.1 packages/core: specifiers: @@ -127,7 +127,7 @@ importers: typescript-json-schema: ^0.53.1 vite: ^2.9.9 vite-plugin-dts: ^1.2.0 - vitest: ^0.13.0 + vitest: ^0.13.1 webcola: ^3.4.0 dependencies: '@amoutonbrady/lz-string': 0.0.1 @@ -150,7 +150,7 @@ importers: typescript-json-schema: 0.53.1 vite: 2.9.9 vite-plugin-dts: 1.2.0_vite@2.9.9 - vitest: 0.13.0 + vitest: 0.13.1 packages: @@ -1466,8 +1466,8 @@ packages: dev: true optional: true - /@commitlint/cli/17.0.1: - resolution: {integrity: sha512-5xT1G5pnynR0tk/ms8Ji7yr9lZCeQs4GLVVtyK/gw20w+enoLTVuRKKY9zg88hy9FoCycc/W8iip2xv3c8payg==} + /@commitlint/cli/17.0.2: + resolution: {integrity: sha512-Axe89Js0YzGGd4gxo3JLlF7yIdjOVpG1LbOorGc6PfYF+drBh14PvarSDLzyd2TNqdylUCq9wb9/A88ZjIdyhA==} engines: {node: '>=v14'} hasBin: true dependencies: @@ -1486,11 +1486,11 @@ packages: - '@swc/wasm' dev: true - /@commitlint/config-conventional/17.0.0: - resolution: {integrity: sha512-jttJXBIq3AuQCvUVwxSctCwKfHxxbALE0IB9OIHYCu/eQdOzPxN72pugeZsWDo1VK/T9iFx+MZoPb6Rb1/ylsw==} + /@commitlint/config-conventional/17.0.2: + resolution: {integrity: sha512-MfP0I/JbxKkzo+HXWB7B3WstGS4BiniotU3d3xQ9gK8cR0DbeZ4MuyGCWF65YDyrcDTS3WlrJ3ndSPA1pqhoPw==} engines: {node: '>=v14'} dependencies: - conventional-changelog-conventionalcommits: 4.6.3 + conventional-changelog-conventionalcommits: 5.0.0 dev: true /@commitlint/config-validator/17.0.0: @@ -3372,8 +3372,8 @@ packages: q: 1.5.1 dev: true - /conventional-changelog-conventionalcommits/4.6.3: - resolution: {integrity: sha512-LTTQV4fwOM4oLPad317V/QNQ1FY4Hju5qeBIM1uTHbrnCE+Eg4CdRZ3gO2pUeR+tzWdp80M2j3qFFEDWVqOV4g==} + /conventional-changelog-conventionalcommits/5.0.0: + resolution: {integrity: sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==} engines: {node: '>=10'} dependencies: compare-func: 2.0.0 @@ -6809,13 +6809,13 @@ packages: dev: true /once/1.4.0: - resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=} + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: wrappy: 1.0.2 dev: true /onetime/2.0.1: - resolution: {integrity: sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=} + resolution: {integrity: sha512-oyyPpiMaKARvvcgip+JV+7zci5L8D1W9RZIz2l1o08AM3pfspitVWnPt3mzHcBPp12oYMTy0pqrFs/C+m3EwsQ==} engines: {node: '>=4'} dependencies: mimic-fn: 1.2.0 @@ -6851,7 +6851,7 @@ packages: dev: true /os-tmpdir/1.0.2: - resolution: {integrity: sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=} + resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} dev: true @@ -6894,7 +6894,7 @@ packages: dev: true /p-locate/2.0.0: - resolution: {integrity: sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=} + resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==} engines: {node: '>=4'} dependencies: p-limit: 1.3.0 @@ -6940,7 +6940,7 @@ packages: dev: true /p-try/1.0.0: - resolution: {integrity: sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=} + resolution: {integrity: sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==} engines: {node: '>=4'} dev: true @@ -6977,7 +6977,7 @@ packages: dev: true /parse-json/4.0.0: - resolution: {integrity: sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=} + resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==} engines: {node: '>=4'} dependencies: error-ex: 1.3.2 @@ -7007,7 +7007,7 @@ packages: dev: false /parse-passwd/1.0.0: - resolution: {integrity: sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=} + resolution: {integrity: sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==} engines: {node: '>=0.10.0'} dev: true @@ -7031,7 +7031,7 @@ packages: dev: true /path-exists/3.0.0: - resolution: {integrity: sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=} + resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} engines: {node: '>=4'} dev: true @@ -7041,7 +7041,7 @@ packages: dev: true /path-is-absolute/1.0.1: - resolution: {integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=} + resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} dev: true @@ -9146,8 +9146,8 @@ packages: fsevents: 2.3.2 dev: true - /vitest/0.13.0: - resolution: {integrity: sha512-vuYt3+G25MMnANgyMHHG3VK86C9K/VFi/8uH5myQ2v660W4WArv99ElakPlVFxxSXXM1jqQPiPj2ht35Bod9LQ==} + /vitest/0.13.1: + resolution: {integrity: sha512-CfSBf7YFw/i8HumSUQRtZKs0aV91DC9WU8nAgIJAlawKHaFuPHQohDwOTPIFgrxySiuFYUa0Yohf9gDFfBwjxA==} engines: {node: '>=v14.16.0'} hasBin: true peerDependencies: @@ -9180,8 +9180,8 @@ packages: - supports-color dev: true - /vitest/0.13.0_sass@1.52.1: - resolution: {integrity: sha512-vuYt3+G25MMnANgyMHHG3VK86C9K/VFi/8uH5myQ2v660W4WArv99ElakPlVFxxSXXM1jqQPiPj2ht35Bod9LQ==} + /vitest/0.13.1_sass@1.52.1: + resolution: {integrity: sha512-CfSBf7YFw/i8HumSUQRtZKs0aV91DC9WU8nAgIJAlawKHaFuPHQohDwOTPIFgrxySiuFYUa0Yohf9gDFfBwjxA==} engines: {node: '>=v14.16.0'} hasBin: true peerDependencies: diff --git a/src/components/EditorSection/DragHandle.tsx b/src/components/EditorSection/DragHandle.tsx new file mode 100644 index 0000000..4d463df --- /dev/null +++ b/src/components/EditorSection/DragHandle.tsx @@ -0,0 +1,72 @@ +import { type ComponentProps, onMount, onCleanup } from "solid-js"; +import IconDragHandleX from "~icons/fluent/re-order-dots-vertical-24-filled"; +import IconDragHandleY from "~icons/fluent/re-order-dots-horizontal-24-filled"; + +export function DragHandle(props?: ComponentProps<'div'> & { + direction?: 'x' | 'y'; +}) { + let ref: HTMLDivElement = null; + let targetEl: HTMLElement = null; + + // The current position of mouse + let position = 0; + + // Size of previous element + let size = 0; + + let sizeProp = props?.direction == "x" ? "width" : "height"; + let mouseDir = props?.direction == "x" ? "clientX" : "clientY"; + let cursorProp = props?.direction == "x" ? "col-resize" : "row-resize"; + + function drag (e: MouseEvent) { + // How far the mouse has been moved + const diff = e[mouseDir] - position; + const newSize = size + diff; + + targetEl.style[sizeProp] = `${newSize}px`; + document.body.style.cursor = cursorProp; + + targetEl.style.userSelect = 'none'; + targetEl.style.pointerEvents = 'none'; + } + + function stopDrag () { + ref.style.removeProperty('cursor'); + document.body.style.removeProperty('cursor'); + + targetEl.style.removeProperty('user-select'); + targetEl.style.removeProperty('pointer-events'); + + document.removeEventListener('pointermove', drag); + document.removeEventListener('pointerup', stopDrag); + } + + onMount(() => { + targetEl = ref.previousElementSibling as HTMLElement; + }); + + onCleanup(() => { + document.removeEventListener('pointermove', drag); + document.removeEventListener('pointerup', stopDrag); + }); + + // Handle the pointerdown event + // that's triggered when user drags the resizer + function pointerDown (e: MouseEvent) { + // Get the current mouse position + position = e[mouseDir]; + size = targetEl.getBoundingClientRect()[sizeProp]; + + // Attach the listeners to `document` + document.addEventListener('pointermove', drag); + document.addEventListener('pointerup', stopDrag); + } + + return ( +
+ {props?.direction == "x" ? : } +
+ ); +} + +export default DragHandle; \ No newline at end of file diff --git a/src/components/EditorSection/Editor.astro b/src/components/EditorSection/Editor.astro index e69de29..2f0bf89 100644 --- a/src/components/EditorSection/Editor.astro +++ b/src/components/EditorSection/Editor.astro @@ -0,0 +1,10 @@ +--- +import Icon from "astro-icon"; +import Container from "../Container.astro"; +import Tabs from "./Tabs.astro"; + +--- + + + + diff --git a/src/components/EditorSection/EditorSection.astro b/src/components/EditorSection/EditorSection.astro index 80bfcb7..11bed74 100644 --- a/src/components/EditorSection/EditorSection.astro +++ b/src/components/EditorSection/EditorSection.astro @@ -8,92 +8,92 @@ import SearchBar from "../Search/SearchBar.astro"; import ProductHunt from "../ProductHunt.astro"; --- - - -
-
-
-
- - - -
+ + +
+
+
+
+ + +
-
-
+
+
+
-
-
- - -
-
Wait...
-
+
+
+ + +
+
Wait...
-
-
-
-
-
-
- -
+
+
+
+
+
+
+
-
-
-
-
- + +
+ -
- - - - - + -
- - -
+ - +
+ +
+
-
-
-
+
+
+
-
-
+    
+
           

Console

@@ -124,35 +124,35 @@ import ProductHunt from "../ProductHunt.astro";
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
- - -
-
Wait...
-
+
+
+ + +
+
Wait...
-
-
- -

Analysis

-
-
-

- -

-
-
-
-
-

Nothing to analyze...

- -
-
- -
-
+

+
+
+
+
+

Nothing to analyze...

+
+
+ +
+
-
-
\ No newline at end of file +
+ +
\ No newline at end of file diff --git a/src/components/EditorSection/Tabs.astro b/src/components/EditorSection/Tabs.astro new file mode 100644 index 0000000..e84061d --- /dev/null +++ b/src/components/EditorSection/Tabs.astro @@ -0,0 +1,47 @@ +--- +import Icon from "astro-icon"; +import Button from "../Button"; + +--- + +
+ + + +
+ + \ No newline at end of file diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 3dec028..a242c86 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -45,6 +45,10 @@ import Button from "./Button"; :global([custom-theme-switch]) { @apply px-2 py-2 rounded-md; } + + :global(svg) { + @apply w-6 h-6; + } } [custom-button] { @@ -58,8 +62,4 @@ import Button from "./Button"; @apply bg-primary/20 hover:bg-primary/40; } } - - :global(svg) { - @apply w-6 h-6; - } \ No newline at end of file diff --git a/src/components/SearchSection/Result.tsx b/src/components/SearchSection/Result.tsx index abeaa5a..6b17389 100644 --- a/src/components/SearchSection/Result.tsx +++ b/src/components/SearchSection/Result.tsx @@ -106,13 +106,13 @@ export function ErrorResult(props?: SearchResultProps) { let _description = props?.description ?? ""; return ( -
-
+
+

{_name}

-

{_description}

+

{_description}

); diff --git a/src/components/SearchSection/SearchContainer.tsx b/src/components/SearchSection/SearchContainer.tsx index 286e98e..caaeba8 100644 --- a/src/components/SearchSection/SearchContainer.tsx +++ b/src/components/SearchSection/SearchContainer.tsx @@ -7,32 +7,42 @@ import SearchResults from "./SearchResults"; export function SearchContainer() { const [getQuery, setQuery] = createSignal(""); - let ref: HTMLDivElement = null; + let ref: HTMLDivElement & { open?: boolean } = null; function onClick(e?: MouseEvent) { let target = e.target as HTMLElement; + + if (ref?.open && !ref.contains(target)) { + e?.stopPropagation?.(); + + ref.open = false; + ref.style.pointerEvents = "none"; + } + } + + function onFocus(e?: MouseEvent) { + let target = e.target as HTMLElement; if (ref.contains(target)) { - // @ts-ignore - if (!ref?.open) ref.open = true; + if (!ref?.open) { + ref.open = true; + ref.style.pointerEvents = "auto"; + } } - // @ts-ignore else if (ref?.open) { e?.stopPropagation?.(); - - // @ts-ignore ref.open = false; } } onMount(() => { document.addEventListener("click", onClick); - document.addEventListener("focusin", onClick); + document.addEventListener("focusin", onFocus); }); onCleanup(() => { document.removeEventListener("click", onClick); - document.removeEventListener("focusin", onClick); + document.removeEventListener("focusin", onFocus); }); return ( diff --git a/src/components/SearchSection/SearchResults.tsx b/src/components/SearchSection/SearchResults.tsx index bf41318..055331c 100644 --- a/src/components/SearchSection/SearchResults.tsx +++ b/src/components/SearchSection/SearchResults.tsx @@ -1,4 +1,4 @@ -import { type ComponentProps, type Accessor, For, createResource, Show, onMount, createEffect, on } from "solid-js"; +import { type ComponentProps, type Accessor, For, createResource, onMount, createEffect, on } from "solid-js"; import { SearchResult, ErrorResult, type SearchResultProps } from "./Result"; import Loading from "../Loading"; @@ -8,12 +8,10 @@ export function SearchResults(props?: ComponentProps<'dialog'> & { }) { let ref: HTMLDivElement = null; let heightRef: HTMLDivElement = null; - let opacityRef: HTMLDivElement = null; const [data] = createResource(props?.query, async (source) => { if (ref) { let anim = heightRef.animate({ - opacity: "0", - pointerEvents: "none" + opacity: "0" }, { duration: 300, easing: 'ease-in-out', @@ -40,8 +38,7 @@ export function SearchResults(props?: ComponentProps<'dialog'> & { onMount(() => { if (data.loading) { heightRef.animate({ - opacity: "0", - pointerEvents: "none" + opacity: "0" }, { duration: 300, easing: 'ease-in-out', @@ -56,8 +53,7 @@ export function SearchResults(props?: ComponentProps<'dialog'> & { let last = heightRef?.getBoundingClientRect(); if (!value?.loading) { heightRef.animate({ - opacity: "1", - pointerEvents: "auto" + opacity: "1" }, { duration: 300, easing: 'ease-in-out', diff --git a/src/pages/index.astro b/src/pages/index.astro index c13fe93..59d9041 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -3,6 +3,7 @@ import BaseLayout from '../layouts/BaseLayout.astro'; import Container from "../components/Container.astro"; import SearchContainer from "../components/SearchSection/SearchContainer"; +import Editor from "../components/EditorSection/Editor.astro"; // import EditorSection from "../components/EditorSection/EditorSection.astro"; import { Content as Docs } from "../components/DocsSection/Docs.md"; @@ -20,6 +21,7 @@ import IntroHeader from "../components/IntroHeader.astro"; + diff --git a/src/styles/base.scss b/src/styles/base.scss index 306f47c..f91f06a 100644 --- a/src/styles/base.scss +++ b/src/styles/base.scss @@ -82,6 +82,8 @@ a { display: inline-block; cursor: pointer; + @apply break-words lt-md:break-all; + &:hover { @apply text-primary dark:text-blue-200; } diff --git a/src/styles/components/_search.scss b/src/styles/components/_search.scss index a459397..1c897aa 100644 --- a/src/styles/components/_search.scss +++ b/src/styles/components/_search.scss @@ -20,7 +20,7 @@ dialog.search-container { &:before { content: ""; @apply absolute inset-0; - @apply opacity-0 scale-x-95; + @apply opacity-0; @apply z-10; } @@ -33,7 +33,10 @@ dialog.search-container { @at-root .dom-loaded dialog.search-container { &, - &:before, + &:before { + @apply transition-all duration-[400ms]; + } + & .search, & .search-results { @apply transition-all duration-300; @@ -46,10 +49,10 @@ dialog.search-container { } &[open] { - @apply p-3 pointer-events-auto; + @apply px-3 pt-3 pointer-events-auto; &:before { - @apply scale-x-100 shadow-transparent border-transparent; + @apply shadow-transparent border-transparent; } &:before, @@ -119,13 +122,12 @@ dialog.search-container { @apply grid gap-6 sm:grid-cols-12; @apply p-5; - .content { - @apply flex flex-col gap-3; - @apply col-span-12; + &.error { + @apply flex items-center justify-center; + } - &:not(.error) { - @apply sm:col-span-9; - } + .content { + @apply flex flex-col gap-3 break-words lt-md:break-all; h3 { font-size: 1rem; @@ -147,7 +149,7 @@ dialog.search-container { align-items: center; .btn { - @apply py-2; + @apply px-3 py-2; @apply w-full relative block m-0; @apply bg-secondary/10 dark:bg-primary/10; @apply hover:bg-secondary/30 dark:hover:bg-primary/30; -- knotmirror 0.0.1