Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme generator added to the new site #1406

Merged
merged 23 commits into from Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3cee98c
Moving the Theme Builder to website with new name Theme Generator
GomezIvann Dec 2, 2022
41c2a56
Update package and yarn.lock
GomezIvann Dec 2, 2022
deb7173
Removing some warnings from the Theme Generator console
GomezIvann Dec 2, 2022
859458a
Adding some navigability to the theme generator
GomezIvann Dec 2, 2022
7ccc491
Some updates to the Theme Builder
GomezIvann Dec 12, 2022
e431a78
Updates to Theme Generator based on recent call
GomezIvann Dec 14, 2022
6bdfcc3
Removing ts-nocheck from Theme Generator files
GomezIvann Dec 14, 2022
db3f9f3
Better naming for types in theme generator app
GomezIvann Dec 15, 2022
b1a98d9
Merge branch 'master' into gomezivann-themeGenerator
raquelarrojo Dec 16, 2022
16b1f06
Updating Theme Generator widgets to typescript
GomezIvann Dec 16, 2022
15997ca
Merge branch 'gomezivann-themeGenerator' of https://github.com/dxc-te…
GomezIvann Dec 16, 2022
5d8257d
Updating all the components preview to tsx
GomezIvann Dec 16, 2022
45d16cd
Updating some Theme Builder examples
GomezIvann Dec 19, 2022
d69136f
Updating more examples from the theme generator
GomezIvann Dec 19, 2022
a7d0037
New Widgets Layout for the theme generator
GomezIvann Dec 20, 2022
7023391
Fixing component's preview overflow
GomezIvann Dec 20, 2022
69723fc
Merge branch 'master' into gomezivann-themeGenerator
GomezIvann Dec 20, 2022
e297619
More Theme Generator updates
GomezIvann Dec 20, 2022
4151d1e
Merge branch 'gomezivann-themeGenerator' of https://github.com/dxc-te…
GomezIvann Dec 20, 2022
c57d601
Removing unused method
GomezIvann Dec 20, 2022
98fb701
Merge branch 'master' into gomezivann-themeGenerator
raquelarrojo Dec 23, 2022
9918e01
Updates based on feedback
GomezIvann Dec 27, 2022
e0f2bf9
Merge branch 'master' into gomezivann-themeGenerator
raquelarrojo Dec 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7,199 changes: 157 additions & 7,042 deletions website/package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions website/package.json
Expand Up @@ -9,13 +9,16 @@
},
"dependencies": {
"@dxc-technology/halstack-react": "0.0.0-e1386cf",
"@radix-ui/react-popover": "0.1.6",
"@types/styled-components": "^5.1.18",
"axios": "^0.27.2",
"cross-env": "^7.0.3",
"next": "12.1.0",
"raw-loader": "^4.0.2",
"react": "17.0.2",
"react-color": "^2.19.3",
"react-dom": "17.0.2",
"react-error-boundary": "^3.1.4",
"react-live": "^2.4.1",
"react-markdown": "^8.0.0",
"slugify": "^1.6.5",
Expand All @@ -24,6 +27,7 @@
"devDependencies": {
"@types/node": "17.0.2",
"@types/react": "17.0.37",
"@types/react-color": "^3.0.6",
"eslint": "8.5.0",
"eslint-config-next": "12.0.9",
"typescript": "4.5.4"
Expand Down
135 changes: 79 additions & 56 deletions website/pages/_app.tsx
Expand Up @@ -12,29 +12,40 @@ import "../global-styles.css";
import { responsiveSizes } from "../screens/common/variables.js";
import SidenavLogo from "@/common/sidenav/SidenavLogo";
import { useRouter } from "next/router";
import { LinksSectionDetails, LinksSections } from "@/common/pagesList";
import {
LinksSectionDetails,
LinksSections,
themeGeneratorLinks,
} from "@/common/pagesList";
import Link from "next/link";

type NextPageWithLayout = NextPage & {
getLayout?: (page: ReactElement) => ReactNode;
};

type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
};
type ApplicationLayoutWrapperProps = {
condition: boolean;
wrapper: (children: React.ReactNode) => JSX.Element;
children: ReactNode;
};

function MyApp({ Component, pageProps }: AppPropsWithLayout) {
const getLayout = Component.getLayout || ((page) => page);
const ApplicationLayoutWrapper = ({
condition,
wrapper,
children,
}: ApplicationLayoutWrapperProps): JSX.Element => (
<>{condition ? wrapper(children) : children}</>
);

const MyApp = ({ Component, pageProps }: AppPropsWithLayout) => {
const getLayout = Component.getLayout || ((page) => page);
const componentWithLayout = getLayout(<Component {...pageProps} />);

const [filter, setFilter] = useState("");
const { asPath: currentPath } = useRouter();

const onFilterInputChange = ({ value }: { value: string }) => {
setFilter(value);
};

const filteredLinks = useMemo(() => {
const filtered: LinksSectionDetails[] = [];
LinksSections.map((section) => {
Expand All @@ -47,64 +58,76 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
});
return filtered;
}, [filter]);

const onFilterInputChange = ({ value }: { value: string }) => {
setFilter(value);
};

return (
<>
<Head>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon.png" />
</Head>
<HalstackProvider advancedTheme={{}}>
<DxcApplicationLayout
visibilityToggleLabel="Menu"
sidenav={
<DxcApplicationLayout.SideNav title={<SidenavLogo />}>
<DxcApplicationLayout.SideNav.Section>
<DxcTextInput
placeholder="Search docs"
value={filter}
onChange={onFilterInputChange}
size="fillParent"
clearable
margin={{
top: "small",
bottom: "small",
right: "xsmall",
left: "xsmall",
}}
/>
</DxcApplicationLayout.SideNav.Section>
{filteredLinks?.map(({ label, links }) => {
return (
<DxcApplicationLayout.SideNav.Section key={label}>
<DxcApplicationLayout.SideNav.Group title={label}>
{links.map(({ label, path }) => (
<Link key={`${label}-${path}`} href={path} passHref>
<DxcApplicationLayout.SideNav.Link
selected={
currentPath.slice(0, -1) === path ||
currentPath.slice(0, -1) ===
path + "/specifications" ||
currentPath.slice(0, -1) === path + "/usage"
}
>
{label}
</DxcApplicationLayout.SideNav.Link>
</Link>
))}
</DxcApplicationLayout.SideNav.Group>
<HalstackProvider>
<ApplicationLayoutWrapper
condition={!themeGeneratorLinks.includes(currentPath)}
wrapper={(children) => (
<DxcApplicationLayout
visibilityToggleLabel="Menu"
sidenav={
<DxcApplicationLayout.SideNav title={<SidenavLogo />}>
<DxcApplicationLayout.SideNav.Section>
<DxcTextInput
placeholder="Search docs"
value={filter}
onChange={onFilterInputChange}
size="fillParent"
clearable
margin={{
top: "small",
bottom: "small",
right: "xsmall",
left: "xsmall",
}}
/>
</DxcApplicationLayout.SideNav.Section>
);
})}
</DxcApplicationLayout.SideNav>
}
{filteredLinks?.map(({ label, links }) => {
return (
<DxcApplicationLayout.SideNav.Section key={label}>
<DxcApplicationLayout.SideNav.Group title={label}>
{links.map(({ label, path }) => (
<Link key={`${label}-${path}`} href={path} passHref>
<DxcApplicationLayout.SideNav.Link
selected={
currentPath.slice(0, -1) === path ||
currentPath.slice(0, -1) ===
path + "/specifications" ||
currentPath.slice(0, -1) === path + "/usage"
}
>
{label}
</DxcApplicationLayout.SideNav.Link>
</Link>
))}
</DxcApplicationLayout.SideNav.Group>
</DxcApplicationLayout.SideNav.Section>
);
})}
</DxcApplicationLayout.SideNav>
}
>
<DxcApplicationLayout.Main>
<MainContainer>{children}</MainContainer>
</DxcApplicationLayout.Main>
</DxcApplicationLayout>
)}
>
<DxcApplicationLayout.Main>
<MainContainer>{componentWithLayout}</MainContainer>
</DxcApplicationLayout.Main>
</DxcApplicationLayout>
{componentWithLayout}
</ApplicationLayoutWrapper>
</HalstackProvider>
</>
);
}
};

const MainContainer = styled.div`
margin: 80px auto;
Expand Down
15 changes: 15 additions & 0 deletions website/pages/theme-generator/advanced-theme.tsx
@@ -0,0 +1,15 @@
import Head from "next/head";
import ThemeGeneratorPage from "../../screens/theme-generator/ThemeGenerator";

const ThemeGenerator = () => {
return (
<>
<Head>
<title>Advanced theme generator — Halstack Design System</title>
</Head>
<ThemeGeneratorPage />
</>
);
};

export default ThemeGenerator;
15 changes: 15 additions & 0 deletions website/pages/theme-generator/opinionated-theme.tsx
@@ -0,0 +1,15 @@
import Head from "next/head";
import ThemeGeneratorPage from "../../screens/theme-generator/ThemeGenerator";

const ThemeGenerator = () => {
return (
<>
<Head>
<title>Opinionated theme generator — Halstack Design System</title>
</Head>
<ThemeGeneratorPage />
</>
);
};

export default ThemeGenerator;
5 changes: 5 additions & 0 deletions website/screens/common/pagesList.ts
Expand Up @@ -13,6 +13,11 @@ type NavigationLinks = {
nextLink: LinkDetails | null;
};

export const themeGeneratorLinks = [
"/theme-generator/opinionated-theme/",
"/theme-generator/advanced-theme/"
]

const overviewLinks: LinkDetails[] = [
{ label: "Introduction", path: "/overview/introduction" },
];
Expand Down
10 changes: 8 additions & 2 deletions website/screens/common/sidenav/SidenavLogo.tsx
Expand Up @@ -5,7 +5,13 @@ import StatusTag from "@/common/StatusTag";
import React from "react";
import { useRouter } from "next/router";

const SidenavLogo = () => {
type SidenavLogoProps = {
version?: string;
};

const SidenavLogo = ({
version = "Design System",
}: SidenavLogoProps): JSX.Element => {
const { basePath } = useRouter();
const siteVersion = basePath.split("/")[2];

Expand All @@ -21,7 +27,7 @@ const SidenavLogo = () => {
/>
<Title>Halstack</Title>
</Header>
<Subtitle>Design system</Subtitle>
<Subtitle>{version}</Subtitle>
</LogoContainer>
<StatusTag>
{basePath
Expand Down
19 changes: 7 additions & 12 deletions website/screens/principles/themes/ThemesPage.tsx
Expand Up @@ -6,6 +6,7 @@ import {
DxcParagraph,
DxcBulletedList,
} from "@dxc-technology/halstack-react";
import Link from "next/link";
import QuickNavContainer from "@/common/QuickNavContainer";
import PageHeading from "@/common/PageHeading";
import DocFooter from "@/common/DocFooter";
Expand Down Expand Up @@ -64,12 +65,9 @@ const sections = [
about the ones we consider fundamental. The list of configurable
properties is small, but it applies at the component level. You can
generate the theme object using our{" "}
<DxcLink
href="https://developer.dxc.com/tools/react/next/#/themeBuilder"
newWindow
>
opinionated theme generator
</DxcLink>
<Link href="/theme-generator/opinionated-theme" passHref>
<DxcLink>opinionated theme generator</DxcLink>
</Link>
.
</DxcBulletedList.Item>
<DxcBulletedList.Item>
Expand All @@ -81,12 +79,9 @@ const sections = [
decisions are structural to the component. The list of configurable
properties is large, and it applies at the component level. You can
generate the theme object using our{" "}
<DxcLink
href="https://developer.dxc.com/tools/react/next/#/themeBuilder/advancedTheme"
newWindow
>
advanced theme generator
</DxcLink>
<Link href="/theme-generator/advanced-theme" passHref>
<DxcLink>advanced theme generator</DxcLink>
</Link>
.
</DxcBulletedList.Item>
</DxcBulletedList>
Expand Down