From b614604effda51ca7c76c8901be78ced62b642b2 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 28 May 2020 16:17:13 +0200 Subject: Update TS migration to current dev, move to a common package, rename to frontend --- .../frontend/src/main/components/app/index.scss | 21 +++++++++ .../frontend/src/main/components/app/index.tsx | 50 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 plugins/base/frontend/src/main/components/app/index.scss create mode 100644 plugins/base/frontend/src/main/components/app/index.tsx (limited to 'plugins/base/frontend/src/main/components/app') diff --git a/plugins/base/frontend/src/main/components/app/index.scss b/plugins/base/frontend/src/main/components/app/index.scss new file mode 100644 index 00000000..c267bc6e --- /dev/null +++ b/plugins/base/frontend/src/main/components/app/index.scss @@ -0,0 +1,21 @@ +@import "src/main/scss/index.scss"; + +html, +.app-root { + height: 100%; +} + +.search-root { + margin: 0; + padding: 0; + + background: var(--ring-content-background-color); + + font-family: var(--ring-font-family); + font-size: var(--ring-font-size); + line-height: var(--ring-line-height); +} + +.search-content { + padding: 24px 41px; +} diff --git a/plugins/base/frontend/src/main/components/app/index.tsx b/plugins/base/frontend/src/main/components/app/index.tsx new file mode 100644 index 00000000..1a51e699 --- /dev/null +++ b/plugins/base/frontend/src/main/components/app/index.tsx @@ -0,0 +1,50 @@ +import React, {useEffect, useRef, useState} from 'react'; +import {WithFuzzySearchFilter} from '../search/search'; +import './index.scss'; + +function useComponentVisible(initialIsVisible: boolean) { + const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible); + const ref = useRef(null); + + const handleHideDropdown = (event: KeyboardEvent) => { + if (event.key === "Escape") { + setIsComponentVisible(false); + } + }; + + const handleClickOutside = (event : MouseEvent)=> { + // @ts-ignore + if (ref.current && !ref.current.contains(event.target)) { + setIsComponentVisible(false); + } + }; + + useEffect(() => { + document.addEventListener("keydown", handleHideDropdown, false); + document.addEventListener("click", handleClickOutside, false); + return () => { + document.removeEventListener("keydown", handleHideDropdown, false); + document.removeEventListener("click", handleClickOutside, false); + }; + }); + + return { ref, isComponentVisible, setIsComponentVisible }; +} + +const App: React.FC = () => { + const { + ref, + isComponentVisible, + setIsComponentVisible + } = useComponentVisible(false); + + return
+ {isComponentVisible && ()} + {!isComponentVisible && ( + setIsComponentVisible(true)}> + + )} +
+} + +export default App -- cgit From 77c8777b7f66bddd374d68decd507547d356d602 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Sun, 31 May 2020 21:02:46 +0200 Subject: Improve CSS, pages navigation tree and create anchors on page --- core/src/main/kotlin/pages/ContentNodes.kt | 14 +- core/src/main/kotlin/pages/PageNodes.kt | 1 - .../frontend/src/main/components/app/index.scss | 8 +- .../frontend/src/main/components/app/index.tsx | 45 +-- .../src/main/components/search/search.scss | 14 + .../frontend/src/main/components/search/search.tsx | 16 +- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 258 +++++++++++----- .../kotlin/renderers/html/htmlPreprocessors.kt | 20 +- .../kotlin/signatures/KotlinSignatureProvider.kt | 2 +- .../documentables/DefaultPageCreator.kt | 67 ++--- .../documentables/PageContentBuilder.kt | 14 +- .../src/main/resources/dokka/scripts/clipboard.js | 52 ++++ .../resources/dokka/scripts/navigationLoader.js | 11 + .../base/src/main/resources/dokka/styles/style.css | 330 ++++++++++++++++++--- .../kotlin/content/params/ContentForParamsTest.kt | 146 ++++----- .../content/seealso/ContentForSeeAlsoTest.kt | 170 +++++------ plugins/base/src/test/kotlin/enums/EnumsTest.kt | 8 + .../kotlin/linkableContent/LinkableContentTest.kt | 4 +- plugins/base/src/test/kotlin/markdown/LinkTest.kt | 13 +- .../test/kotlin/renderers/RenderingOnlyTestBase.kt | 1 + .../test/kotlin/renderers/html/DivergentTest.kt | 26 +- 21 files changed, 842 insertions(+), 378 deletions(-) create mode 100644 plugins/base/frontend/src/main/components/search/search.scss create mode 100644 plugins/base/src/main/resources/dokka/scripts/clipboard.js (limited to 'plugins/base/frontend/src/main/components/app') diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 95b7b371..d6105bec 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -13,6 +13,8 @@ interface ContentNode : WithExtraProperties { val dci: DCI val sourceSets: Set val style: Set