Skip to content

Commit

Permalink
Update publish (open-metadata#197)
Browse files Browse the repository at this point in the history
* updated the connectors list on the homepage

* added padding to the tabs selection container

* open-metadata#193: Refactored side nav bar for how to guides page (open-metadata#196)

* refactored side nav bar to for how to guides page to show selected section items only

* Icon name improvements

---------

Co-authored-by: Sachin Chaurasiya <[email protected]>
  • Loading branch information
aniketkatkar97 and Sachin-chaurasiya authored Dec 1, 2023
1 parent 398e441 commit 17a9e1f
Show file tree
Hide file tree
Showing 21 changed files with 475 additions and 376 deletions.
546 changes: 301 additions & 245 deletions components/ConnectorsInfo/ConnectorsInfo.constants.ts

Large diffs are not rendered by default.

59 changes: 50 additions & 9 deletions components/ConnectorsInfo/ConnectorsInfo.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
.Container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
gap: 30px;
.Container{
display: flex;
gap: 8px;
height: 500px;
overflow-y: hidden;
}

.TabsContainer{
flex: 0 0 auto;
width: 200px;
padding-right: 16px;
border-right: 1px solid var(--default-border-color);
}

.TabItem{
padding: 8px;
cursor: pointer;
border-radius: 4px;
}

.TabItem:hover{
background-color: var(--primary-background-color);
}

.SelectedTab{
border: 0.5px solid var(--select-border-color);
background-color: var(--primary-background-color);
color: var(--primary-color);
font-weight: 600;
}

.ConnectorsContainer{
max-height: 100%;
overflow-y: scroll;
}

.ConnectorsGridContainer {
display: flex;
flex-wrap: wrap;
justify-items: flex-start;
justify-content: flex-start;
height: fit-content;
gap: 20px;
padding: 16px;
}

.ConnectorItem {
color: var(--default-text-color);
display: flex;
height: 100%;
height: 65px;
width: 200px;
align-items: center;
gap: 10px;
transition: box-shadow 0.2s linear;
Expand All @@ -29,25 +70,25 @@
}

@media (max-width: 1200px) {
.Container {
.ConnectorsGridContainer {
grid-template-columns: 1fr 1fr 1fr 1fr;
}
}

@media (max-width: 900px) {
.Container {
.ConnectorsGridContainer {
grid-template-columns: 1fr 1fr 1fr;
}
}

@media (max-width: 600px) {
.Container {
.ConnectorsGridContainer {
grid-template-columns: 1fr 1fr;
}
}

@media (max-width: 600px) {
.Container {
.ConnectorsGridContainer {
gap: 16px;
}
.ConnectorImg {
Expand Down
75 changes: 61 additions & 14 deletions components/ConnectorsInfo/ConnectorsInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,70 @@
import React from "react";
import { connectorsArr } from "./ConnectorsInfo.constants";
import styles from "./ConnectorsInfo.module.css";
import classNames from "classnames";
import { sortBy } from "lodash";
import Link from "next/link";
import { useState } from "react";
import { CONNECTORS } from "./ConnectorsInfo.constants";
import styles from "./ConnectorsInfo.module.css";

interface ConnectorCategory {
connector: string;
services: {
url: string;
icon: string;
name: string;
}[];
}

CONNECTORS.unshift({
connector: "All connectors",
services: CONNECTORS.reduce((prev, curr) => {
return sortBy(
[...prev, ...curr.services],
[(connector) => connector.name.toLowerCase()]
);
}, [] as ConnectorCategory["services"]),
});

export default function ConnectorsInfo() {
const [selectedTab, setSelectedTab] = useState<ConnectorCategory>(
CONNECTORS[0]
);

return (
<div className={styles.Container}>
{connectorsArr.map((connector) => (
<Link href={connector.url} key={connector.name}>
<div className={styles.ConnectorItem} key={connector.name}>
<img
className={styles.ConnectorImg}
src={connector.icon}
alt={connector.name}
/>
<p>{connector.name}</p>
<div className={styles.TabsContainer}>
{CONNECTORS.map((connectorCategory) => (
<div
className={classNames(
styles.TabItem,
connectorCategory.connector === selectedTab.connector
? styles.SelectedTab
: ""
)}
key={connectorCategory.connector}
onClick={() => setSelectedTab(connectorCategory)}
>
{connectorCategory.connector}
</div>
</Link>
))}
))}
</div>
<div className={styles.ConnectorsContainer}>
<div className={styles.ConnectorsGridContainer}>
{selectedTab.services.map((connector) => (
<Link
className={styles.ConnectorItem}
href={connector.url}
key={connector.name}
>
<img
className={styles.ConnectorImg}
src={connector.icon}
alt={connector.name}
/>
<p>{connector.name}</p>
</Link>
))}
</div>
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion components/HowToGuidesHeader/HowToGuidesHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function HowToGuidesHeader() {
padding: "8px 12px",
}}
type="link"
href="/how-to-guides/openmetadata/data-discovery"
href="/how-to-guides/data-discovery"
>
<span>Get Started</span>
<MdOutlineArrowForwardIos size={10} />
Expand Down
6 changes: 6 additions & 0 deletions components/SideNav/ListItem.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { MenuItem } from "../../interface/common.interface";

export interface ListItemProps {
item: MenuItem;
fontWeight?: number;
}
16 changes: 7 additions & 9 deletions components/SideNav/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import classNames from "classnames";
import { isNil } from "lodash";
import Link from "next/link";
import { useRouter } from "next/router";
import { useEffect, useMemo, useRef, useState } from "react";
import { useDocVersionContext } from "../../context/DocVersionContext";
import { ReactComponent as ArrowDown } from "../../images/icons/drop-arrow-down.svg";
import { ReactComponent as ArrowRight } from "../../images/icons/drop-arrow-right.svg";
import { ReactComponent as CollateIcon } from "../../images/icons/ic-collate.svg";
import { MenuItem } from "../../interface/common.interface";
import { getUrlWithVersion } from "../../utils/CommonUtils";
import { ListItemProps } from "./ListItem.interface";
import styles from "./SideNav.module.css";

export default function ListItem({
item,
fontWeight,
}: {
item: MenuItem;
fontWeight?: number;
}) {
export default function ListItem({ item, fontWeight }: Readonly<ListItemProps>) {
const router = useRouter();
const { docVersion } = useDocVersionContext();
const linkRef = useRef<HTMLAnchorElement>();
Expand Down Expand Up @@ -65,7 +60,10 @@ export default function ListItem({

useEffect(() => {
// Logic to get the selected side nav item into view after page load
if (linkRef.current && linkRef.current.className.includes("ActiveLink")) {
if (
!isNil(linkRef.current) &&
linkRef.current.className.includes("ActiveLink")
) {
linkRef.current.scrollIntoView({ block: "center", inline: "center" });
}
}, [isActive, linkRef]);
Expand Down
6 changes: 5 additions & 1 deletion components/SideNav/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ReactComponent as CollapseLeftIcon } from "../../images/icons/collapse-
import { ReactComponent as CollapseRightIcon } from "../../images/icons/collapse-right.svg";
import { ReactComponent as OverviewIcon } from "../../images/icons/overview-icon.svg";
import { getCategoryByIndex } from "../../lib/utils";
import { getSideNavItems } from "../../utils/SideNavUtils";
import SkeletonLoader from "../common/SkeletonLoader/SkeletonLoader";
import ListItem from "./ListItem";
import styles from "./SideNav.module.css";
Expand Down Expand Up @@ -42,7 +43,10 @@ export default forwardRef(function SideNav(
[menuItems, category]
);

const childItems = useMemo(() => item?.children ?? [], [item]);
const childItems = useMemo(
() => getSideNavItems(item, router.asPath),
[item, router.asPath]
);

useEffect(() => {
const scrollEventListener = () => {
Expand Down
25 changes: 14 additions & 11 deletions components/TopNav/TopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
import { useDocVersionContext } from "../../context/DocVersionContext";
import { useNavBarCollapsedContext } from "../../context/NavBarCollapseContext";
import { SearchContextProvider } from "../../context/SearchContext";
import { ReactComponent as API } from "../../images/icons/api.svg";
import { ReactComponent as Cloud } from "../../images/icons/cloud.svg";
import { ReactComponent as Github } from "../../images/icons/github.svg";
import { ReactComponent as SvgLogo } from "../../images/icons/omd.svg";
import { ReactComponent as Slack } from "../../images/icons/slack.svg";
import { ReactComponent as ApiIcon } from "../../images/icons/api.svg";
import { ReactComponent as CloudIcon } from "../../images/icons/cloud.svg";
import { ReactComponent as GithubIcon } from "../../images/icons/github.svg";
import { ReactComponent as OMDIcon } from "../../images/icons/omd.svg";
import { ReactComponent as SlackIcon } from "../../images/icons/slack.svg";
import { getUrlWithVersion } from "../../utils/CommonUtils";
import Search from "../Search/Search";
import SelectDropdown, { SelectOption } from "../SelectDropdown/SelectDropdown";
Expand All @@ -33,7 +33,7 @@ interface TopNavProps {
versionsList: Array<SelectOption<string>>;
}

export default function TopNav({ versionsList }: TopNavProps) {
export default function TopNav({ versionsList }: Readonly<TopNavProps>) {
const router = useRouter();
const [displayNavBarCollapseButton, setDisplayNavBarCollapseButton] =
useState(false);
Expand Down Expand Up @@ -88,7 +88,7 @@ export default function TopNav({ versionsList }: TopNavProps) {
<div className={styles.CollapsedDivContainer}>
<div className={styles.LogoContainer}>
<Link href={docVersion ? getUrlWithVersion("/", docVersion) : "/"}>
<SvgLogo />
<OMDIcon />
</Link>
{!isEmpty(versionsList) && (
<SelectDropdown
Expand All @@ -111,31 +111,34 @@ export default function TopNav({ versionsList }: TopNavProps) {
<InstantSearch
indexName={`openmetadata-v1-${docVersion}`}
searchClient={searchClient}
future={{
preserveSharedStateOnUnmount: false,
}}
>
<Search />
</InstantSearch>
</SearchContextProvider>
<div className={styles.IconContainer}>
<a href="https://slack.open-metadata.org" target="_blank" title="Slack">
<Slack />
<SlackIcon />
</a>
<a
href="https://github.com/open-metadata/OpenMetadata"
target="_blank"
title="Github"
>
<Github />
<GithubIcon />
</a>
<a href="/swagger.html" target="_blank" title="Swagger">
<API />
<ApiIcon />
</a>
<a
className="btn fw-500 btn-primary rounded-pill"
href="https://cloud.getcollate.io"
target="_blank"
>
<button className={styles.CloudBtn}>
<Cloud />
<CloudIcon />
</button>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/common/SkeletonLoader/SkeletonLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function SkeletonLoader({
showBreadcrumb = false,
title = DEFAULT_TITLE,
paragraph = DEFAULT_PARAGRAPH,
}: SkeletonLoaderProps) {
}: Readonly<SkeletonLoaderProps>) {
return (
<div className={classNames(styles.Container, className)}>
{showBreadcrumb && getSkeletonBreadcrumbs()}
Expand Down
6 changes: 5 additions & 1 deletion components/modals/APISearchModal/APISearchModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import algoliasearch from "algoliasearch/lite";
import { isNil } from "lodash";
import { useEffect } from "react";
import ReactDOM from "react-dom";
import { InstantSearch } from "react-instantsearch";
Expand All @@ -23,7 +24,7 @@ function APISearchModal({ handleMaskClick }: APISearchModalProps) {
setTimeout(() => {
const inputElement = document.getElementById("search-input");

inputElement && inputElement.focus();
!isNil(inputElement) && inputElement.focus();
}, 50);
}, []);

Expand All @@ -38,6 +39,9 @@ function APISearchModal({ handleMaskClick }: APISearchModalProps) {
<InstantSearch
indexName={`openmetadata-v1-${docVersion}`}
searchClient={searchClient}
future={{
preserveSharedStateOnUnmount: false, // Library recommendation to keep the old behavior
}}
>
<Search
className={styles.SearchContainer}
Expand Down
1 change: 1 addition & 0 deletions constants/SideNav.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const HOW_TO_GUIDES_MENU_ITEM_KEY = "how-to-guides";
Loading

0 comments on commit 17a9e1f

Please sign in to comment.