@redocly/theme 0.1.6 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Footer/Footer.d.ts +3 -0
- package/Footer/Footer.js +35 -0
- package/Footer/FooterColumn.d.ts +7 -0
- package/Footer/FooterColumn.js +39 -0
- package/Footer/FooterColumns.d.ts +7 -0
- package/Footer/FooterColumns.js +44 -0
- package/Footer/FooterCopyright.d.ts +5 -0
- package/Footer/FooterCopyright.js +30 -0
- package/Footer/index.d.ts +4 -0
- package/Footer/index.js +20 -0
- package/JsonViewer/JsonViewer.js +1 -1
- package/JsonViewer/index.d.ts +1 -0
- package/JsonViewer/index.js +1 -0
- package/Layout/PageLayout.d.ts +6 -0
- package/Layout/PageLayout.js +31 -0
- package/Layout/RootLayout.d.ts +7 -0
- package/Layout/RootLayout.js +32 -0
- package/Layout/index.d.ts +2 -0
- package/Layout/index.js +18 -0
- package/Logo/Logo.d.ts +1 -6
- package/Logo/index.d.ts +1 -0
- package/Logo/index.js +17 -0
- package/Markdown/Admonition.d.ts +9 -0
- package/Markdown/Admonition.js +39 -0
- package/Markdown/CodeSample/CodeSample.d.ts +8 -0
- package/Markdown/CodeSample/CodeSample.js +30 -0
- package/Markdown/CodeSample/index.d.ts +3 -0
- package/Markdown/CodeSample/index.js +19 -0
- package/Markdown/CodeSample/styled.d.ts +5 -0
- package/Markdown/CodeSample/styled.js +109 -0
- package/Markdown/CodeSample/types.d.ts +9 -0
- package/Markdown/CodeSample/types.js +2 -0
- package/Markdown/ContentWrapper.d.ts +5 -0
- package/Markdown/ContentWrapper.js +21 -0
- package/Markdown/Heading.d.ts +5 -0
- package/Markdown/Heading.js +23 -0
- package/Markdown/MarkdownLayout.d.ts +7 -0
- package/Markdown/MarkdownLayout.js +23 -0
- package/Markdown/Mermaid.d.ts +6 -0
- package/Markdown/Mermaid.js +19 -0
- package/Markdown/PageWrapper.d.ts +3 -0
- package/Markdown/PageWrapper.js +15 -0
- package/Markdown/StyledMarkdown.d.ts +8 -0
- package/Markdown/StyledMarkdown.js +54 -0
- package/Markdown/Tabs/Tab.d.ts +8 -0
- package/Markdown/Tabs/Tab.js +35 -0
- package/Markdown/Tabs/Tabs.d.ts +10 -0
- package/Markdown/Tabs/Tabs.js +43 -0
- package/Markdown/Tabs/index.d.ts +2 -0
- package/Markdown/Tabs/index.js +18 -0
- package/Markdown/index.d.ts +9 -0
- package/Markdown/index.js +25 -0
- package/Navbar/Navbar.d.ts +2 -1
- package/Navbar/Navbar.js +9 -3
- package/Navbar/NavbarItem.d.ts +1 -1
- package/Navbar/NavbarItem.js +3 -3
- package/Navbar/NavbarMenu.d.ts +1 -1
- package/Navbar/NavbarMenu.js +8 -4
- package/OperationBadge/OperationBadge.d.ts +5 -0
- package/OperationBadge/OperationBadge.js +15 -0
- package/OperationBadge/index.d.ts +1 -0
- package/OperationBadge/index.js +17 -0
- package/PageNavigation/NextPageLink.d.ts +2 -0
- package/PageNavigation/NextPageLink.js +25 -0
- package/PageNavigation/PageNavigation.d.ts +2 -0
- package/PageNavigation/PageNavigation.js +31 -0
- package/PageNavigation/PreviousPageLink.d.ts +2 -0
- package/PageNavigation/PreviousPageLink.js +25 -0
- package/Panel/CodePanel.js +6 -6
- package/Panel/ContentPanel.js +4 -4
- package/Panel/Panel.d.ts +1 -1
- package/Panel/Panel.js +3 -3
- package/Panel/PanelComponent.d.ts +1 -1
- package/Panel/PanelComponent.js +3 -3
- package/Panel/index.d.ts +1 -0
- package/Panel/index.js +1 -0
- package/Search/Autocomplete.d.ts +13 -0
- package/Search/Autocomplete.js +79 -0
- package/Search/ClearIcon.d.ts +2 -0
- package/Search/ClearIcon.js +29 -0
- package/Search/Input.d.ts +3 -0
- package/Search/Input.js +15 -0
- package/Search/Parameters.d.ts +7 -0
- package/Search/Parameters.js +42 -0
- package/Search/Popover.d.ts +3 -0
- package/Search/Popover.js +15 -0
- package/Search/Search.d.ts +2 -0
- package/Search/Search.js +39 -0
- package/Search/SearchIcon.d.ts +2 -0
- package/Search/SearchIcon.js +29 -0
- package/Search/SearchItem.d.ts +7 -0
- package/Search/SearchItem.js +47 -0
- package/Search/index.d.ts +9 -0
- package/Search/index.js +25 -0
- package/Search/utils.d.ts +2 -0
- package/Search/utils.js +21 -0
- package/Sidebar/ApiCallItem.d.ts +8 -0
- package/Sidebar/ApiCallItem.js +35 -0
- package/Sidebar/ArrowBack.d.ts +4 -0
- package/Sidebar/ArrowBack.js +29 -0
- package/Sidebar/BackButton.d.ts +6 -0
- package/Sidebar/BackButton.js +31 -0
- package/Sidebar/Drilldown.d.ts +8 -0
- package/Sidebar/Drilldown.js +46 -0
- package/Sidebar/DrilldownMenu.d.ts +3 -0
- package/Sidebar/DrilldownMenu.js +55 -0
- package/Sidebar/DrilldownMenuItem.d.ts +3 -0
- package/Sidebar/DrilldownMenuItem.js +32 -0
- package/Sidebar/ExternalIcon.d.ts +4 -0
- package/Sidebar/ExternalIcon.js +29 -0
- package/Sidebar/Menu.d.ts +3 -0
- package/Sidebar/Menu.js +15 -0
- package/Sidebar/MenuContainer.d.ts +1 -0
- package/Sidebar/MenuContainer.js +13 -0
- package/Sidebar/MenuGroup.d.ts +9 -0
- package/Sidebar/MenuGroup.js +37 -0
- package/Sidebar/MenuItem.d.ts +3 -0
- package/Sidebar/MenuItem.js +34 -0
- package/Sidebar/MenuItemLabel.d.ts +5 -0
- package/Sidebar/MenuItemLabel.js +19 -0
- package/Sidebar/MenuLink.d.ts +5 -0
- package/Sidebar/MenuLink.js +16 -0
- package/Sidebar/MenuLinkItem.d.ts +3 -0
- package/Sidebar/MenuLinkItem.js +31 -0
- package/Sidebar/MobileSidebarButton.d.ts +5 -0
- package/Sidebar/MobileSidebarButton.js +21 -0
- package/Sidebar/Separator.d.ts +3 -0
- package/Sidebar/Separator.js +32 -0
- package/Sidebar/SeparatorItem.d.ts +5 -0
- package/Sidebar/SeparatorItem.js +14 -0
- package/Sidebar/SeparatorLine.d.ts +3 -0
- package/Sidebar/SeparatorLine.js +15 -0
- package/Sidebar/Sidebar.d.ts +8 -0
- package/Sidebar/Sidebar.js +24 -0
- package/Sidebar/SidebarLayout.d.ts +7 -0
- package/Sidebar/SidebarLayout.js +36 -0
- package/Sidebar/index.d.ts +19 -0
- package/Sidebar/index.js +35 -0
- package/Sidebar/types/DrilldownMenuProps.d.ts +6 -0
- package/Sidebar/types/DrilldownMenuProps.js +2 -0
- package/Sidebar/types/ItemState.d.ts +8 -0
- package/Sidebar/types/ItemState.js +2 -0
- package/Sidebar/types/MenuItemProps.d.ts +5 -0
- package/Sidebar/types/MenuItemProps.js +2 -0
- package/Sidebar/types/MenuStyle.d.ts +3 -0
- package/Sidebar/types/MenuStyle.js +8 -0
- package/Sidebar/types/NavItem.d.ts +26 -0
- package/Sidebar/types/NavItem.js +2 -0
- package/Sidebar/types/index.d.ts +5 -0
- package/Sidebar/types/index.js +21 -0
- package/SourceCode/SourceCode.js +2 -2
- package/TableOfContent/TableOfContent.d.ts +9 -0
- package/TableOfContent/TableOfContent.js +65 -0
- package/TableOfContent/index.d.ts +1 -0
- package/TableOfContent/index.js +17 -0
- package/globalStyle.js +1 -1
- package/hooks/index.d.ts +4 -0
- package/hooks/index.js +4 -0
- package/hooks/useActiveHeading.d.ts +2 -0
- package/hooks/useActiveHeading.js +34 -0
- package/hooks/useActiveSectionId.d.ts +3 -0
- package/hooks/useActiveSectionId.js +48 -0
- package/hooks/useFullHeight.d.ts +2 -0
- package/hooks/useFullHeight.js +47 -0
- package/hooks/useMobileMenu.d.ts +2 -0
- package/hooks/useMobileMenu.js +13 -0
- package/hooks/useNavbarHeight.d.ts +3 -0
- package/hooks/useNavbarHeight.js +20 -0
- package/icons/ShelfIcon/ShelfIcon.js +2 -2
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/mocks/hooks/usePageData.d.ts +5 -0
- package/mocks/hooks/usePageData.js +7 -0
- package/mocks/models.d.ts +3 -0
- package/mocks/models.js +2 -0
- package/mocks/search.d.ts +22 -0
- package/mocks/search.js +13 -0
- package/mocks/types/index.d.ts +1 -0
- package/mocks/types/index.js +2 -0
- package/mocks/usePreloadHistory.d.ts +3 -0
- package/mocks/usePreloadHistory.js +12 -0
- package/package.json +5 -2
- package/src/Button/Button.stories.tsx +1 -1
- package/src/Button/__tests__/Button.test.tsx +1 -1
- package/src/CodeBlock/__tests__/CodeBlock.test.tsx +1 -1
- package/src/CopyButton/CopyButton.stories.tsx +1 -1
- package/src/CopyButton/CopyButton.tsx +1 -1
- package/src/CopyButton/CopyButtonWrapper.tsx +4 -4
- package/src/CopyButton/__tests__/CopyButton.test.tsx +1 -1
- package/src/CopyButton/__tests__/CopyButtonWrapper.test.tsx +2 -1
- package/src/Footer/Footer.tsx +34 -0
- package/src/Footer/FooterColumn.tsx +62 -0
- package/src/Footer/FooterColumns.tsx +51 -0
- package/src/Footer/FooterCopyright.tsx +26 -0
- package/src/Footer/index.ts +4 -0
- package/src/Headings/Headings.stories.tsx +1 -1
- package/src/Headings/Headings.ts +1 -1
- package/src/Headings/__tests__/Headings.test.tsx +1 -1
- package/src/JsonViewer/JsonViewer.stories.tsx +1 -1
- package/src/JsonViewer/JsonViewer.tsx +6 -7
- package/src/JsonViewer/__tests__/JsonViewer.test.tsx +2 -1
- package/src/JsonViewer/index.ts +1 -0
- package/src/Layout/PageLayout.tsx +34 -0
- package/src/Layout/RootLayout.tsx +24 -0
- package/src/Layout/index.ts +2 -0
- package/src/Logo/Logo.tsx +1 -7
- package/src/Logo/index.ts +1 -0
- package/src/Markdown/Admonition.tsx +64 -0
- package/src/Markdown/CodeSample/CodeSample.tsx +39 -0
- package/src/Markdown/CodeSample/index.ts +3 -0
- package/src/Markdown/CodeSample/styled.ts +289 -0
- package/src/Markdown/CodeSample/types.ts +40 -0
- package/src/Markdown/ContentWrapper.tsx +20 -0
- package/src/Markdown/Heading.tsx +35 -0
- package/src/Markdown/MarkdownLayout.tsx +25 -0
- package/src/Markdown/Mermaid.tsx +23 -0
- package/src/Markdown/PageWrapper.tsx +9 -0
- package/src/Markdown/StyledMarkdown.tsx +312 -0
- package/src/Markdown/Tabs/Tab.tsx +37 -0
- package/src/Markdown/Tabs/Tabs.tsx +45 -0
- package/src/Markdown/Tabs/index.ts +2 -0
- package/src/Markdown/index.ts +9 -0
- package/src/Navbar/Navbar.stories.tsx +3 -13
- package/src/Navbar/Navbar.tsx +20 -26
- package/src/Navbar/NavbarItem.tsx +2 -2
- package/src/Navbar/NavbarMenu.tsx +6 -6
- package/src/OperationBadge/OperationBadge.stories.tsx +35 -0
- package/src/OperationBadge/OperationBadge.ts +59 -0
- package/src/OperationBadge/__tests__/OperationBadge.test.tsx +59 -0
- package/src/OperationBadge/__tests__/__snapshots__/OperationBadge.test.tsx.snap +651 -0
- package/src/OperationBadge/index.ts +1 -0
- package/src/PageNavigation/NextPageLink.tsx +22 -0
- package/src/PageNavigation/PageNavigation.tsx +20 -0
- package/src/PageNavigation/PreviousPageLink.tsx +22 -0
- package/src/Panel/CodePanel.stories.tsx +1 -2
- package/src/Panel/CodePanel.ts +8 -7
- package/src/Panel/ContentPanel.stories.tsx +1 -2
- package/src/Panel/ContentPanel.ts +5 -6
- package/src/Panel/Panel.stories.tsx +1 -3
- package/src/Panel/Panel.ts +3 -3
- package/src/Panel/PanelComponent.tsx +4 -5
- package/src/Panel/__tests__/CodePanel.test.tsx +1 -1
- package/src/Panel/__tests__/ContentPanel.test.tsx +1 -1
- package/src/Panel/__tests__/Panel.test.tsx +1 -2
- package/src/Panel/__tests__/__snapshots__/CodePanel.test.tsx.snap +8 -8
- package/src/Panel/__tests__/__snapshots__/ContentPanel.test.tsx.snap +22 -22
- package/src/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +16 -16
- package/src/Panel/index.ts +1 -0
- package/src/SamplesPanelControls/SamplesControlButton.stories.tsx +1 -1
- package/src/SamplesPanelControls/SamplesPanelControls.ts +1 -1
- package/src/Search/Autocomplete.tsx +128 -0
- package/src/Search/ClearIcon.tsx +31 -0
- package/src/Search/Input.tsx +19 -0
- package/src/Search/Parameters.tsx +62 -0
- package/src/Search/Popover.tsx +20 -0
- package/src/Search/Search.tsx +52 -0
- package/src/Search/SearchIcon.tsx +32 -0
- package/src/Search/SearchItem.tsx +85 -0
- package/src/Search/index.ts +9 -0
- package/src/Search/utils.tsx +19 -0
- package/src/Sidebar/ApiCallItem.tsx +33 -0
- package/src/Sidebar/ArrowBack.tsx +22 -0
- package/src/Sidebar/BackButton.tsx +44 -0
- package/src/Sidebar/Drilldown.tsx +46 -0
- package/src/Sidebar/DrilldownMenu.tsx +58 -0
- package/src/Sidebar/DrilldownMenuItem.tsx +40 -0
- package/src/Sidebar/ExternalIcon.tsx +37 -0
- package/src/Sidebar/Menu.tsx +11 -0
- package/src/Sidebar/MenuContainer.tsx +8 -0
- package/src/Sidebar/MenuGroup.tsx +55 -0
- package/src/Sidebar/MenuItem.tsx +25 -0
- package/src/Sidebar/MenuItemLabel.tsx +41 -0
- package/src/Sidebar/MenuLink.tsx +14 -0
- package/src/Sidebar/MenuLinkItem.tsx +24 -0
- package/src/Sidebar/MobileSidebarButton.tsx +44 -0
- package/src/Sidebar/Separator.tsx +17 -0
- package/src/Sidebar/SeparatorItem.tsx +14 -0
- package/src/Sidebar/SeparatorLine.tsx +9 -0
- package/src/Sidebar/Sidebar.tsx +54 -0
- package/src/Sidebar/SidebarLayout.tsx +30 -0
- package/src/Sidebar/index.ts +19 -0
- package/src/Sidebar/types/DrilldownMenuProps.ts +7 -0
- package/src/Sidebar/types/ItemState.ts +9 -0
- package/src/Sidebar/types/MenuItemProps.ts +6 -0
- package/src/Sidebar/types/MenuStyle.ts +4 -0
- package/src/Sidebar/types/NavItem.ts +27 -0
- package/src/Sidebar/types/index.ts +5 -0
- package/src/SidebarLogo/SidebarLogo.stories.tsx +1 -1
- package/src/SidebarLogo/__tests__/SidebarLogo.test.tsx +1 -1
- package/src/SourceCode/SourceCode.stories.tsx +1 -1
- package/src/SourceCode/SourceCode.tsx +7 -3
- package/src/SourceCode/__tests__/SourceCode.test.tsx +2 -1
- package/src/TableOfContent/TableOfContent.stories.tsx +39 -0
- package/src/TableOfContent/TableOfContent.tsx +112 -0
- package/src/TableOfContent/index.ts +1 -0
- package/src/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/Tooltip/Tooltip.tsx +1 -1
- package/src/Tooltip/__tests__/Tooltip.test.tsx +1 -1
- package/src/globalStyle.ts +10 -73
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useActiveHeading.ts +46 -0
- package/src/hooks/useActiveSectionId.ts +53 -0
- package/src/hooks/useFullHeight.ts +47 -0
- package/src/hooks/useMobileMenu.ts +11 -0
- package/src/hooks/useNavbarHeight.ts +24 -0
- package/src/icons/ShelfIcon/ShelfIcon.stories.tsx +1 -1
- package/src/icons/ShelfIcon/ShelfIcon.tsx +1 -1
- package/src/icons/ShelfIcon/__tests__/ShelfIcon.test.tsx +1 -1
- package/src/index.ts +2 -0
- package/src/mocks/hooks/usePageData.ts +8 -0
- package/src/mocks/models.ts +3 -0
- package/src/mocks/search.ts +31 -0
- package/src/mocks/types/index.ts +1 -0
- package/src/mocks/usePreloadHistory.ts +9 -0
- package/src/types/portal/index.d.ts +6 -0
- package/src/types/portal/src/client/app/Sidebar/types.d.ts +50 -0
- package/src/types/portal/src/client/app/media-css.d.ts +7 -0
- package/src/types/portal/src/client/styling/default.d.ts +407 -0
- package/src/types/portal/src/client/styling/index.d.ts +14 -0
- package/src/types/portal/src/client/styling/resolve.d.ts +1 -0
- package/src/types/portal/src/server/constants.d.ts +11 -0
- package/src/types/portal/src/server/plugins/markdown/types.d.ts +28 -0
- package/src/types/portal/src/server/plugins/nav-utils.d.ts +19 -0
- package/src/types/portal/src/server/plugins/portal-config/types.d.ts +23 -0
- package/src/types/portal/src/server/plugins/sidebars/index.d.ts +16 -0
- package/src/types/portal/src/server/plugins/versions/index.d.ts +15 -0
- package/src/types/portal/src/server/plugins/versions/types.d.ts +23 -0
- package/src/types/portal/src/server/plugins/versions/utils.d.ts +10 -0
- package/src/types/portal/src/server/store.d.ts +101 -0
- package/src/types/portal/src/server/utils/async.d.ts +5 -0
- package/src/types/portal/src/server/utils/crypto.d.ts +3 -0
- package/src/types/portal/src/server/utils/fs.d.ts +3 -0
- package/src/types/portal/src/server/utils/index.d.ts +6 -0
- package/src/types/portal/src/server/utils/paths.d.ts +16 -0
- package/src/types/portal/src/server/utils/reporter/formatter.d.ts +11 -0
- package/src/types/portal/src/server/utils/reporter/reporter.d.ts +17 -0
- package/src/types/portal/src/server/utils/watcher.d.ts +16 -0
- package/src/types/portal/src/server/utils/yaml.d.ts +1 -0
- package/src/types/portal/src/shared/constants.d.ts +8 -0
- package/src/types/portal/src/shared/types.d.ts +77 -0
- package/src/types/portal/src/shared/urls.d.ts +7 -0
- package/src/types/portal/src/shared/utils.d.ts +10 -0
- package/src/ui/AlertIcon.tsx +110 -0
- package/src/ui/Arrow.tsx +36 -0
- package/src/ui/Background.tsx +16 -0
- package/src/ui/Box.tsx +39 -0
- package/src/ui/Button.tsx +19 -0
- package/src/ui/Dropdown.tsx +132 -0
- package/src/ui/Flex.tsx +21 -0
- package/src/ui/Jumbotron.tsx +57 -0
- package/src/ui/Tiles/ThinTile.tsx +151 -0
- package/src/ui/Tiles/TileHeader.ts +13 -0
- package/src/ui/Tiles/TileText.tsx +12 -0
- package/src/ui/Tiles/WideTile.tsx +138 -0
- package/src/ui/Tiles/index.ts +4 -0
- package/src/ui/Typography.tsx +167 -0
- package/src/ui/UniversalLink.tsx +100 -0
- package/src/ui/index.tsx +17 -0
- package/src/utils/__tests__/ClipboardService.test.ts +1 -1
- package/src/utils/__tests__/css-variables.test.ts +1 -1
- package/src/utils/__tests__/highlight.test.ts +1 -1
- package/src/utils/__tests__/jsonToHtml.test.ts +1 -1
- package/src/utils/__tests__/media-css.test.ts +1 -1
- package/src/utils/__tests__/theme-helpers.test.ts +1 -1
- package/src/utils/getNavbarElement.ts +10 -0
- package/src/utils/isUrl.ts +42 -0
- package/src/utils/replaceHashInColor.ts +3 -0
- package/ui/AlertIcon.d.ts +9 -0
- package/ui/AlertIcon.js +45 -0
- package/ui/Arrow.d.ts +7 -0
- package/ui/Arrow.js +42 -0
- package/ui/Background.d.ts +7 -0
- package/ui/Background.js +16 -0
- package/ui/Box.d.ts +6 -0
- package/ui/Box.js +16 -0
- package/ui/Button.d.ts +7 -0
- package/ui/Button.js +27 -0
- package/ui/Dropdown.d.ts +8 -0
- package/ui/Dropdown.js +55 -0
- package/ui/Flex.d.ts +10 -0
- package/ui/Flex.js +31 -0
- package/ui/Jumbotron.d.ts +18 -0
- package/ui/Jumbotron.js +44 -0
- package/ui/Tiles/ThinTile.d.ts +21 -0
- package/ui/Tiles/ThinTile.js +98 -0
- package/ui/Tiles/TileHeader.d.ts +5 -0
- package/ui/Tiles/TileHeader.js +15 -0
- package/ui/Tiles/TileText.d.ts +5 -0
- package/ui/Tiles/TileText.js +15 -0
- package/ui/Tiles/WideTile.d.ts +7 -0
- package/ui/Tiles/WideTile.js +93 -0
- package/ui/Tiles/index.d.ts +4 -0
- package/ui/Tiles/index.js +20 -0
- package/ui/Typography.d.ts +110 -0
- package/ui/Typography.js +137 -0
- package/ui/UniversalLink.d.ts +17 -0
- package/ui/UniversalLink.js +62 -0
- package/ui/index.d.ts +14 -0
- package/ui/index.js +34 -0
- package/utils/getNavbarElement.d.ts +1 -0
- package/utils/getNavbarElement.js +14 -0
- package/utils/isUrl.d.ts +12 -0
- package/utils/isUrl.js +36 -0
- package/utils/replaceHashInColor.d.ts +1 -0
- package/utils/replaceHashInColor.js +7 -0
package/src/Panel/CodePanel.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
|
-
import { ShelfIcon } from '
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { PanelHeaderTitle } from './PanelHeaderTitle';
|
|
3
|
+
import { ShelfIcon } from '@theme/icons/ShelfIcon';
|
|
4
|
+
import { Panel } from '@theme/Panel/Panel';
|
|
5
|
+
import { PanelHeader } from '@theme/Panel/PanelHeader';
|
|
6
|
+
import { DarkHeader } from '@theme/Panel/DarkHeader';
|
|
7
|
+
import { PanelBody } from '@theme/Panel/PanelBody';
|
|
8
|
+
import { PanelHeaderTitle } from '@theme/Panel/PanelHeaderTitle';
|
|
10
9
|
|
|
11
10
|
export const CodePanel = styled(Panel)`
|
|
12
11
|
> ${PanelHeader} {
|
|
13
12
|
${DarkHeader};
|
|
14
13
|
min-height: 50px;
|
|
14
|
+
|
|
15
15
|
${ShelfIcon} {
|
|
16
16
|
fill: var(--color-content-inverse);
|
|
17
17
|
position: relative;
|
|
18
18
|
}
|
|
19
|
+
|
|
19
20
|
${PanelHeaderTitle} {
|
|
20
21
|
color: var(--color-content-inverse);
|
|
21
22
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, { JSXElementConstructor } from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
3
|
|
|
4
|
-
import { ContentPanel } from '
|
|
5
|
-
import { PanelComponentProps } from './PanelComponent';
|
|
4
|
+
import { ContentPanel, PanelComponentProps } from '@theme/Panel';
|
|
6
5
|
|
|
7
6
|
export default {
|
|
8
7
|
title: 'Components/Panels/ContentPanel',
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
|
-
import { ShelfIcon } from '
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { PanelHeader } from './PanelHeader';
|
|
3
|
+
import { ShelfIcon } from '@theme/icons/ShelfIcon';
|
|
4
|
+
import { PanelHeaderTitle } from '@theme/Panel/PanelHeaderTitle';
|
|
5
|
+
import { Panel } from '@theme/Panel/Panel';
|
|
6
|
+
import { PanelBody } from '@theme/Panel/PanelBody';
|
|
7
|
+
import { PanelHeader } from '@theme/Panel/PanelHeader';
|
|
9
8
|
|
|
10
9
|
export const ContentPanel = styled(Panel)`
|
|
11
10
|
border: 1px solid var(--global-border-color);
|
|
@@ -2,9 +2,7 @@ import React, { JSXElementConstructor } from 'react';
|
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
3
|
import { within, userEvent } from '@storybook/testing-library';
|
|
4
4
|
|
|
5
|
-
import { Panel } from '
|
|
6
|
-
import { PanelHeaderProps } from './PanelHeader';
|
|
7
|
-
import { PanelComponentProps } from './PanelComponent';
|
|
5
|
+
import { Panel, PanelHeaderProps, PanelComponentProps } from '@theme/Panel';
|
|
8
6
|
|
|
9
7
|
export default {
|
|
10
8
|
title: 'Components/Panels/Panel (base)',
|
package/src/Panel/Panel.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { PanelHeader } from '@theme/Panel/PanelHeader';
|
|
4
|
+
import { PanelBody } from '@theme/Panel/PanelBody';
|
|
5
|
+
import { PanelComponent } from '@theme/Panel/PanelComponent';
|
|
6
6
|
|
|
7
7
|
export const Panel = styled(PanelComponent)`
|
|
8
8
|
border-radius: var(--panels-border-radius);
|
|
@@ -7,11 +7,10 @@ import React, {
|
|
|
7
7
|
} from 'react';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
|
|
10
|
-
import { ShelfIcon } from '
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { PanelHeaderTitle } from './PanelHeaderTitle';
|
|
10
|
+
import { ShelfIcon } from '@theme/icons';
|
|
11
|
+
import { PanelBody } from '@theme/Panel/PanelBody';
|
|
12
|
+
import { PanelHeader, PanelHeaderProps } from '@theme/Panel/PanelHeader';
|
|
13
|
+
import { PanelHeaderTitle } from '@theme/Panel/PanelHeaderTitle';
|
|
15
14
|
|
|
16
15
|
export interface PanelComponentProps {
|
|
17
16
|
expanded?: boolean;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
|
|
4
|
-
import { Panel } from '
|
|
5
|
-
import { PanelHeaderProps } from '../PanelHeader';
|
|
4
|
+
import { Panel, PanelHeaderProps } from '@theme/Panel';
|
|
6
5
|
|
|
7
6
|
describe('Panel', () => {
|
|
8
7
|
it('renders without header', () => {
|
|
@@ -130,14 +130,6 @@ exports[`CodePanel renders expanded 1`] = `
|
|
|
130
130
|
transition: transform 0.2s ease-out;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
.c10 {
|
|
134
|
-
border-top-left-radius: var(--panels-border-radius);
|
|
135
|
-
border-top-right-radius: var(--panels-border-radius);
|
|
136
|
-
border-bottom-right-radius: var(--panels-border-radius);
|
|
137
|
-
border-bottom-left-radius: var(--panels-border-radius);
|
|
138
|
-
background-color: var(--panels-background-color);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
133
|
.c3 {
|
|
142
134
|
position: relative;
|
|
143
135
|
z-index: 1;
|
|
@@ -162,6 +154,14 @@ exports[`CodePanel renders expanded 1`] = `
|
|
|
162
154
|
pointer-events: auto;
|
|
163
155
|
}
|
|
164
156
|
|
|
157
|
+
.c10 {
|
|
158
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
159
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
160
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
161
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
162
|
+
background-color: var(--panels-background-color);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
165
|
.c6 {
|
|
166
166
|
line-height: 1;
|
|
167
167
|
margin-right: 5px;
|
|
@@ -14,13 +14,6 @@ exports[`ContentPanel renders collapsed 1`] = `
|
|
|
14
14
|
transition: transform 0.2s ease-out;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.c6 {
|
|
18
|
-
line-height: 1;
|
|
19
|
-
margin-right: 5px;
|
|
20
|
-
font-weight: 700;
|
|
21
|
-
color: var(--color-content);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
17
|
.c3 {
|
|
25
18
|
position: relative;
|
|
26
19
|
z-index: 1;
|
|
@@ -45,6 +38,13 @@ exports[`ContentPanel renders collapsed 1`] = `
|
|
|
45
38
|
pointer-events: auto;
|
|
46
39
|
}
|
|
47
40
|
|
|
41
|
+
.c6 {
|
|
42
|
+
line-height: 1;
|
|
43
|
+
margin-right: 5px;
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
color: var(--color-content);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
48
|
.c4 {
|
|
49
49
|
display: -webkit-inline-box;
|
|
50
50
|
display: -webkit-inline-flex;
|
|
@@ -139,21 +139,6 @@ exports[`ContentPanel renders expanded 1`] = `
|
|
|
139
139
|
transition: transform 0.2s ease-out;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
.c6 {
|
|
143
|
-
line-height: 1;
|
|
144
|
-
margin-right: 5px;
|
|
145
|
-
font-weight: 700;
|
|
146
|
-
color: var(--color-content);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.c10 {
|
|
150
|
-
border-top-left-radius: var(--panels-border-radius);
|
|
151
|
-
border-top-right-radius: var(--panels-border-radius);
|
|
152
|
-
border-bottom-right-radius: var(--panels-border-radius);
|
|
153
|
-
border-bottom-left-radius: var(--panels-border-radius);
|
|
154
|
-
background-color: var(--panels-background-color);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
142
|
.c3 {
|
|
158
143
|
position: relative;
|
|
159
144
|
z-index: 1;
|
|
@@ -178,6 +163,21 @@ exports[`ContentPanel renders expanded 1`] = `
|
|
|
178
163
|
pointer-events: auto;
|
|
179
164
|
}
|
|
180
165
|
|
|
166
|
+
.c10 {
|
|
167
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
168
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
169
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
170
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
171
|
+
background-color: var(--panels-background-color);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.c6 {
|
|
175
|
+
line-height: 1;
|
|
176
|
+
margin-right: 5px;
|
|
177
|
+
font-weight: 700;
|
|
178
|
+
color: var(--color-content);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
181
|
.c4 {
|
|
182
182
|
display: -webkit-inline-box;
|
|
183
183
|
display: -webkit-inline-flex;
|
|
@@ -100,14 +100,6 @@ exports[`Panel renders collapsed 1`] = `
|
|
|
100
100
|
`;
|
|
101
101
|
|
|
102
102
|
exports[`Panel renders expanded 1`] = `
|
|
103
|
-
.c7 {
|
|
104
|
-
border-top-left-radius: var(--panels-border-radius);
|
|
105
|
-
border-top-right-radius: var(--panels-border-radius);
|
|
106
|
-
border-bottom-right-radius: var(--panels-border-radius);
|
|
107
|
-
border-bottom-left-radius: var(--panels-border-radius);
|
|
108
|
-
background-color: var(--panels-background-color);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
103
|
.c5 {
|
|
112
104
|
height: 9px;
|
|
113
105
|
width: 9px;
|
|
@@ -145,6 +137,14 @@ exports[`Panel renders expanded 1`] = `
|
|
|
145
137
|
pointer-events: auto;
|
|
146
138
|
}
|
|
147
139
|
|
|
140
|
+
.c7 {
|
|
141
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
142
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
143
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
144
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
145
|
+
background-color: var(--panels-background-color);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
148
|
.c4 {
|
|
149
149
|
line-height: 1;
|
|
150
150
|
margin-right: 5px;
|
|
@@ -218,14 +218,6 @@ exports[`Panel renders expanded 1`] = `
|
|
|
218
218
|
`;
|
|
219
219
|
|
|
220
220
|
exports[`Panel renders with header 1`] = `
|
|
221
|
-
.c7 {
|
|
222
|
-
border-top-left-radius: var(--panels-border-radius);
|
|
223
|
-
border-top-right-radius: var(--panels-border-radius);
|
|
224
|
-
border-bottom-right-radius: var(--panels-border-radius);
|
|
225
|
-
border-bottom-left-radius: var(--panels-border-radius);
|
|
226
|
-
background-color: var(--panels-background-color);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
221
|
.c5 {
|
|
230
222
|
height: 9px;
|
|
231
223
|
width: 9px;
|
|
@@ -263,6 +255,14 @@ exports[`Panel renders with header 1`] = `
|
|
|
263
255
|
pointer-events: auto;
|
|
264
256
|
}
|
|
265
257
|
|
|
258
|
+
.c7 {
|
|
259
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
260
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
261
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
262
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
263
|
+
background-color: var(--panels-background-color);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
266
|
.c4 {
|
|
267
267
|
line-height: 1;
|
|
268
268
|
margin-right: 5px;
|
package/src/Panel/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
3
|
|
|
4
|
-
import { SampleControls, SamplesControlButton } from '
|
|
4
|
+
import { SampleControls, SamplesControlButton } from '@theme/SamplesPanelControls';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Samples Control Button',
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
KeyboardEvent,
|
|
4
|
+
ReactNode,
|
|
5
|
+
SyntheticEvent,
|
|
6
|
+
useEffect,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import { useLocation } from 'react-router-dom';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
|
|
12
|
+
import { FormInput } from '@theme/Search/Input';
|
|
13
|
+
import { Popover } from '@theme/Search/Popover';
|
|
14
|
+
import { ActiveItem } from '@shared/models';
|
|
15
|
+
|
|
16
|
+
interface AutocompleteProps<T> {
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
value: string;
|
|
19
|
+
items: T[];
|
|
20
|
+
renderItem(item: ActiveItem<T>): ReactNode;
|
|
21
|
+
change(value: string): void;
|
|
22
|
+
select(item: T): void;
|
|
23
|
+
children?(isOpen: boolean, close: () => void): ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function Autocomplete<T>({
|
|
27
|
+
placeholder,
|
|
28
|
+
value,
|
|
29
|
+
items,
|
|
30
|
+
change,
|
|
31
|
+
select,
|
|
32
|
+
renderItem,
|
|
33
|
+
children,
|
|
34
|
+
}: AutocompleteProps<T>): JSX.Element {
|
|
35
|
+
const location = useLocation();
|
|
36
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
37
|
+
const [activeIdx, setActiveIdx] = useState(-1);
|
|
38
|
+
|
|
39
|
+
const open = () => setIsOpen(true);
|
|
40
|
+
const close = () => {
|
|
41
|
+
setIsOpen(false);
|
|
42
|
+
setActiveIdx(-1);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const reset = () => {
|
|
46
|
+
change('');
|
|
47
|
+
close();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const stopPropagation = (event: SyntheticEvent) => event.stopPropagation();
|
|
51
|
+
|
|
52
|
+
const onChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
53
|
+
setActiveIdx(-1);
|
|
54
|
+
change(event.target.value);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const onKeydown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
58
|
+
switch (event.code) {
|
|
59
|
+
case 'Escape':
|
|
60
|
+
close();
|
|
61
|
+
event.currentTarget.blur();
|
|
62
|
+
break;
|
|
63
|
+
case 'ArrowDown':
|
|
64
|
+
setActiveIdx(Math.min(activeIdx + 1, items.length - 1));
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
break;
|
|
67
|
+
case 'ArrowUp':
|
|
68
|
+
setActiveIdx(Math.max(0, activeIdx - 1));
|
|
69
|
+
break;
|
|
70
|
+
case 'Enter':
|
|
71
|
+
if (activeIdx > -1) {
|
|
72
|
+
select(items[activeIdx]);
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const mapItem = (item: T, idx: number) => {
|
|
79
|
+
const active = idx === activeIdx;
|
|
80
|
+
return renderItem({ ...item, active });
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
useEffect(close, [location]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Wrapper data-component-name="Search/Autocomplete">
|
|
87
|
+
{isOpen ? <Overlay onClick={close} /> : null}
|
|
88
|
+
<AutocompleteBox onKeyDown={onKeydown}>
|
|
89
|
+
<FormInput
|
|
90
|
+
value={value}
|
|
91
|
+
placeholder={placeholder}
|
|
92
|
+
onChange={onChange}
|
|
93
|
+
onFocus={open}
|
|
94
|
+
onClick={stopPropagation}
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
{children?.(isOpen, reset)}
|
|
98
|
+
|
|
99
|
+
{isOpen && value ? (
|
|
100
|
+
<Popover>{items.length ? items.map(mapItem) : <Message>No results</Message>}</Popover>
|
|
101
|
+
) : null}
|
|
102
|
+
</AutocompleteBox>
|
|
103
|
+
</Wrapper>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const Wrapper = styled.div``;
|
|
108
|
+
|
|
109
|
+
const AutocompleteBox = styled.div`
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
position: relative;
|
|
113
|
+
z-index: 1;
|
|
114
|
+
`;
|
|
115
|
+
|
|
116
|
+
const Overlay = styled.div`
|
|
117
|
+
position: fixed;
|
|
118
|
+
top: 0;
|
|
119
|
+
left: 0;
|
|
120
|
+
right: 0;
|
|
121
|
+
bottom: 0;
|
|
122
|
+
z-index: 1;
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
const Message = styled.div`
|
|
126
|
+
padding: 24px;
|
|
127
|
+
color: var(--color-text-main);
|
|
128
|
+
`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { SVGProps } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
const Icon = (props: SVGProps<SVGSVGElement>) => (
|
|
5
|
+
<span data-component-name="Search/ClearIcon">
|
|
6
|
+
<svg
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
version="1.1"
|
|
9
|
+
x="0"
|
|
10
|
+
y="0"
|
|
11
|
+
viewBox="0 0 298.7 298.7"
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<polygon points="298.7 30.2 268.5 0 149.3 119.1 30.2 0 0 30.2 119.1 149.3 0 268.5 30.2 298.7 149.3 179.5 268.5 298.7 298.7 268.5 179.5 149.3 " />
|
|
15
|
+
</svg>
|
|
16
|
+
</span>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const ClearIcon = styled(Icon)`
|
|
20
|
+
position: absolute;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
width: 0.5em;
|
|
23
|
+
height: 0.5em;
|
|
24
|
+
right: 1.2em;
|
|
25
|
+
fill: var(--input-text-color);
|
|
26
|
+
|
|
27
|
+
${({ theme }) => theme.mediaQueries.medium} {
|
|
28
|
+
width: 0.625em;
|
|
29
|
+
height: 0.625em;
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const FormInput = styled.input.attrs(() => ({
|
|
4
|
+
'data-component-name': 'Search/Input',
|
|
5
|
+
}))`
|
|
6
|
+
padding: 1em 2.5em 1em 1em;
|
|
7
|
+
background-color: var(--input-background-color);
|
|
8
|
+
border-radius: var(--input-border-radius);
|
|
9
|
+
border: none;
|
|
10
|
+
outline: none;
|
|
11
|
+
color: var(--input-text-color);
|
|
12
|
+
font-size: var(--input-font-size);
|
|
13
|
+
font-family: var(--input-font-family);
|
|
14
|
+
line-height: var(--input-line-height);
|
|
15
|
+
|
|
16
|
+
::placeholder {
|
|
17
|
+
color: var(--input-text-color);
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { OperationParameter } from '@shared/models';
|
|
5
|
+
import { highlight } from '@theme/Search/utils';
|
|
6
|
+
|
|
7
|
+
interface ParametersProps {
|
|
8
|
+
parameters: OperationParameter[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const MAX_ITEMS = 2;
|
|
12
|
+
|
|
13
|
+
export function Parameters({ parameters = [] }: ParametersProps): JSX.Element {
|
|
14
|
+
const moreItems = Math.max(0, parameters.length - MAX_ITEMS);
|
|
15
|
+
if (moreItems) {
|
|
16
|
+
parameters.length = MAX_ITEMS;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Wrapper data-component-name="Search/Parameters">
|
|
21
|
+
{parameters.map((param) => {
|
|
22
|
+
const path = `${param.place} → ${
|
|
23
|
+
param.path?.length ? param.path?.join(' → ') + ' → ' : ''
|
|
24
|
+
}`;
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<Place>
|
|
28
|
+
{path}
|
|
29
|
+
{highlight(param.name)} <br />
|
|
30
|
+
{highlight(param.description)}
|
|
31
|
+
</Place>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
})}
|
|
35
|
+
{moreItems ? <MoreText>and {moreItems} more...</MoreText> : null}
|
|
36
|
+
</Wrapper>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Wrapper = styled.div`
|
|
41
|
+
border-left: 1px solid var(--color-border-light);
|
|
42
|
+
padding: 0 12px;
|
|
43
|
+
margin-top: 8px;
|
|
44
|
+
margin-bottom: 4px;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const Place = styled.div`
|
|
48
|
+
font-size: var(--font-size-small);
|
|
49
|
+
padding-top: 8px;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
text-overflow: ellipsis;
|
|
52
|
+
|
|
53
|
+
&:first-child {
|
|
54
|
+
padding-top: 0;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const MoreText = styled.div`
|
|
59
|
+
font-size: var(--font-size-small);
|
|
60
|
+
font-weight: var(--font-weight-light);
|
|
61
|
+
padding-top: 4px;
|
|
62
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Popover = styled.div.attrs(() => ({
|
|
4
|
+
'data-component-name': 'Search/Popover',
|
|
5
|
+
}))`
|
|
6
|
+
position: absolute;
|
|
7
|
+
top: calc(100% + 10px);
|
|
8
|
+
right: 0;
|
|
9
|
+
z-index: 100;
|
|
10
|
+
min-width: 100%;
|
|
11
|
+
width: 550px;
|
|
12
|
+
max-width: 90vw;
|
|
13
|
+
max-height: 400px;
|
|
14
|
+
overflow-y: auto;
|
|
15
|
+
box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12),
|
|
16
|
+
0 8px 10px -5px rgba(0, 0, 0, 0.4);
|
|
17
|
+
background: var(--popover-backgrond-color);
|
|
18
|
+
list-style: none;
|
|
19
|
+
border-radius: var(--popover-border-radius);
|
|
20
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { usePreloadHistory } from '@portal/usePreloadHistory';
|
|
5
|
+
import { useFuseSearch } from '@portal/search';
|
|
6
|
+
import { Autocomplete } from '@theme/Search/Autocomplete';
|
|
7
|
+
import { ClearIcon } from '@theme/Search/ClearIcon';
|
|
8
|
+
import { SearchIcon } from '@theme/Search/SearchIcon';
|
|
9
|
+
import { SearchItem } from '@theme/Search/SearchItem';
|
|
10
|
+
|
|
11
|
+
interface OperationParameter {
|
|
12
|
+
name: string | string[];
|
|
13
|
+
description: string | string[];
|
|
14
|
+
place: string;
|
|
15
|
+
path?: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface SearchDocument {
|
|
19
|
+
id: string;
|
|
20
|
+
url: string;
|
|
21
|
+
title: string | string[];
|
|
22
|
+
text: string | string[];
|
|
23
|
+
path?: string[];
|
|
24
|
+
httpVerb?: string;
|
|
25
|
+
pathName?: string | string[];
|
|
26
|
+
parameters?: OperationParameter[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function Search(): JSX.Element {
|
|
30
|
+
const history = usePreloadHistory();
|
|
31
|
+
const { query, setQuery, items } = useFuseSearch();
|
|
32
|
+
|
|
33
|
+
// TODO: ask somebody about typings
|
|
34
|
+
const navigate = (item: SearchDocument) => history.push(item.url);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Wrapper data-component-name="Search/Search">
|
|
38
|
+
<Autocomplete
|
|
39
|
+
items={items}
|
|
40
|
+
value={query}
|
|
41
|
+
change={setQuery}
|
|
42
|
+
select={navigate}
|
|
43
|
+
placeholder="Search the docs"
|
|
44
|
+
renderItem={(item) => <SearchItem key={item.id} item={item} />}
|
|
45
|
+
>
|
|
46
|
+
{(isOpen, reset) => (isOpen ? <ClearIcon onClick={reset} /> : <SearchIcon />)}
|
|
47
|
+
</Autocomplete>
|
|
48
|
+
</Wrapper>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const Wrapper = styled.div``;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { SVGProps } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
const Icon = (props: SVGProps<SVGSVGElement>) => (
|
|
5
|
+
<span data-component-name="Search/SearchIcon">
|
|
6
|
+
<svg
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
version="1.1"
|
|
9
|
+
x="0"
|
|
10
|
+
y="0"
|
|
11
|
+
viewBox="0 0 490 490"
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<path d="M484 455.2L366.2 337.4c29.2-35.6 46.8-81.2 46.8-130.9C413 92.5 320.5 0 206.5 0 92.4 0 0 92.5 0 206.5S92.4 413 206.5 413c49.7 0 95.2-17.5 130.8-46.7L455.1 484c8 8 20.9 8 28.9 0C492 476.1 492 463.1 484 455.2zM206.5 371.9C115.2 371.9 41 297.7 41 206.5S115.2 41 206.5 41C297.7 41 372 115.3 372 206.5S297.7 371.9 206.5 371.9z" />
|
|
15
|
+
</svg>
|
|
16
|
+
</span>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const SearchIcon = styled(Icon)`
|
|
20
|
+
position: absolute;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
width: 1em;
|
|
23
|
+
height: 1em;
|
|
24
|
+
right: 1em;
|
|
25
|
+
fill: var(--input-text-color);
|
|
26
|
+
z-index: -1;
|
|
27
|
+
|
|
28
|
+
${({ theme }) => theme.mediaQueries.medium} {
|
|
29
|
+
width: 1.2em;
|
|
30
|
+
height: 1.2em;
|
|
31
|
+
}
|
|
32
|
+
`;
|