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

feat: introduced base website redesign layouts #6145

Merged
merged 26 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1afddfa
refactor: updated components to be functional for website redesign
ovflowd Nov 28, 2023
45fbdd4
chore: hooks separate generic hooks
ovflowd Nov 28, 2023
2577575
chore: updated storybook previews for redesign
ovflowd Nov 28, 2023
54bdaf0
chore: removed other languages as they will be translated on crowdin
ovflowd Nov 28, 2023
3d378ad
fix: updated base styles for redesign
ovflowd Nov 28, 2023
5a0ab03
chore: updated types
ovflowd Nov 28, 2023
f9f359c
feat: added new layouts (base, and article layout) and related "provi…
ovflowd Nov 28, 2023
095ee91
feat: updated mdx engine and shared context and app layouts
ovflowd Nov 28, 2023
e3b5532
meta: updated packages, navigation, tailwind config, etc
ovflowd Nov 28, 2023
8efb5b3
chore: moved package to prod deps
ovflowd Nov 28, 2023
86c9da1
fix: mocked module
ovflowd Nov 28, 2023
e914814
chore: design fixes
ovflowd Nov 29, 2023
5035a79
fix: last story fix
ovflowd Nov 29, 2023
fbf4739
meta: mismatch of lock file
ovflowd Nov 29, 2023
9274115
fix: fixed styles and minor content-wise bug fixes
ovflowd Nov 29, 2023
b825e28
fix: home icon go home
ovflowd Nov 29, 2023
c32381b
chore: home aria label
ovflowd Nov 29, 2023
4fa52b7
chore: some minimum design fixes
ovflowd Nov 29, 2023
4099939
refactor: paddings merged
canerakdas Nov 29, 2023
13fcaad
refactor: footer top border added
canerakdas Nov 29, 2023
c09c328
fix: contrast ratio on dark mode breadcrumb
canerakdas Nov 29, 2023
37b3928
fix: colspan changed to 2 for missing border
canerakdas Nov 29, 2023
4b2624f
fix: old layout table heading
canerakdas Nov 30, 2023
5c87ae1
refactor: gradient and shadow colors replaced with theme colors
canerakdas Nov 30, 2023
dc171ea
chore: moved the `with` components to `components`
ovflowd Nov 30, 2023
0d7c5a2
refactor: tw config alpha channel and xl content padding
canerakdas Dec 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .storybook/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Open_Sans, IBM_Plex_Mono } from 'next/font/google';

// This defines "execution" modes that Chromatic will run on the each Storybook Story
// This allows us to test each Story with different parameters
// @see https://www.chromatic.com/blog/introducing-story-modes/
Expand Down Expand Up @@ -28,22 +26,3 @@ export const STORYBOOK_SIZES = {
small: { name: 'Small', styles: { width: '414px', height: '896px' } },
large: { name: 'Large', styles: { width: '1024px', height: '768px' } },
};

// This configures the Next.js Font for Open Sans
// We then export a variable and class name to be used
// within Tailwind (tailwind.config.ts) and Storybook (preview.js)
export const OPEN_SANS_FONT = Open_Sans({
weight: ['300', '400', '600', '700'],
display: 'fallback',
subsets: ['latin'],
variable: '--font-open-sans',
});

// This configures the Next.js Font for IBM Plex Mono
// We then export a variable and class name to be used
// within Tailwind (tailwind.config.ts) and Storybook (preview.js)
export const IBM_PLEX_MONO_FONT = IBM_Plex_Mono({
weight: ['600'],
subsets: ['latin'],
variable: '--font-ibm-plex-mono',
});
7 changes: 1 addition & 6 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ const rootClasses = classNames(
// note: this is hard-coded sadly as next/font can only be loaded within next.js context
'__variable_open-sans-normal',
// note: this is hard-coded sadly as next/font can only be loaded within next.js context
'__variable_ibm-plex-mono-normal-600',
'font-open-sans',
'bg-white',
'text-neutral-950',
'dark:bg-neutral-950',
'dark:text-white'
'__variable_ibm-plex-mono-normal-600'
);

const config: StorybookConfig = {
Expand Down
1 change: 1 addition & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Preview, ReactRenderer } from '@storybook/react';

import englishLocale from '@/i18n/locales/en.json';

import '../next.fonts';
import '../styles/new/index.css';

const preview: Preview = {
Expand Down
18 changes: 15 additions & 3 deletions app/[locale]/[[...path]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,27 @@ const getPage: FC<DynamicParams> = async ({ params }) => {
if (source.length && filename.length) {
// This parses the source Markdown content and returns a React Component and
// relevant context from the Markdown File
const { MDXContent, frontmatter, headings } =
const { MDXContent, frontmatter, headings, readingTime } =
await dynamicRouter.getMDXContent(source, filename);

// Metadata and shared Context to be available through the lifecycle of the page
const sharedContext = {
frontmatter,
headings,
pathname: `/${pathname}`,
readingTime,
filename,
};

// Defines a shared Server Context for the Client-Side
// That is shared for all pages under the dynamic router
setClientContext({ frontmatter, headings, pathname });
setClientContext(sharedContext);

// The Matter Provider allows Client-Side injection of the data
// to a shared React Client Provider even though the page is rendered
// within a server-side context
return (
<MatterProvider matter={frontmatter} headings={headings}>
<MatterProvider {...sharedContext}>
<WithLayout layout={frontmatter.layout}>
<MDXRenderer Component={MDXContent} />
</WithLayout>
Expand Down
30 changes: 20 additions & 10 deletions app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
import { Analytics } from '@vercel/analytics/react';
import { Source_Sans_3 } from 'next/font/google';
import classNames from 'classnames';
import { getLocale } from 'next-intl/server';
import type { FC, PropsWithChildren } from 'react';

import BaseLayout from '@/layouts/BaseLayout';
import { VERCEL_ENV } from '@/next.constants.mjs';
import LegacyBaseLayout from '@/layouts/BaseLayout';
import NewBaseLayout from '@/layouts/New/Base';
import { ENABLE_WEBSITE_REDESIGN, VERCEL_ENV } from '@/next.constants.mjs';
import { IBM_PLEX_MONO, OPEN_SANS, SOURCE_SANS } from '@/next.fonts';
import { availableLocalesMap, defaultLocale } from '@/next.locales.mjs';
import { LocaleProvider } from '@/providers/localeProvider';
import { ThemeProvider } from '@/providers/themeProvider';

import '@/styles/old/index.css';
// Uses a WebPack/TurboPack Alias for resolving Global Styles
// @deprecated remove when website redesign is done
// eslint-disable-next-line import/no-unresolved
import 'globalStyles';

const sourceSans = Source_Sans_3({
weight: ['400', '600'],
display: 'fallback',
subsets: ['latin'],
// Defines the App Fonts based on being on Website Redesign or not
// @deprecated remove when website redesign is done
const fontClasses = classNames(IBM_PLEX_MONO.variable, {
[SOURCE_SANS.className]: !ENABLE_WEBSITE_REDESIGN,
[OPEN_SANS.variable]: ENABLE_WEBSITE_REDESIGN,
});

// Defines the Base Layout based on being on Website Redesign or not
// @deprecated remove when website redesign is done
const AppLayout = ENABLE_WEBSITE_REDESIGN ? NewBaseLayout : LegacyBaseLayout;

const RootLayout: FC<PropsWithChildren> = async ({ children }) => {
const locale = await getLocale();

const { langDir, hrefLang } = availableLocalesMap[locale] || defaultLocale;

return (
<html className={sourceSans.className} dir={langDir} lang={hrefLang}>
<html className={fontClasses} dir={langDir} lang={hrefLang}>
<body suppressHydrationWarning>
<LocaleProvider>
<ThemeProvider>
<BaseLayout>{children}</BaseLayout>
<AppLayout>{children}</AppLayout>
</ThemeProvider>
</LocaleProvider>

Expand Down
4 changes: 4 additions & 0 deletions client-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const getClientContext = cache(() => {
frontmatter: {},
pathname: '',
headings: [],
readingTime: { text: '', minutes: 0, time: 0, words: 0 },
filename: '',
};

return serverSharedContext;
Expand All @@ -21,4 +23,6 @@ export const setClientContext = (data: ClientSharedServerContext) => {
getClientContext().frontmatter = data.frontmatter;
getClientContext().pathname = data.pathname;
getClientContext().headings = data.headings;
getClientContext().readingTime = data.readingTime;
getClientContext().filename = data.filename;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
px-2
py-1
font-semibold
text-white;
text-white
dark:text-white;

&:hover {
@apply bg-green-700
Expand Down
5 changes: 3 additions & 2 deletions components/Common/Breadcrumbs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import BreadcrumbItem from '@/components/Common/Breadcrumbs/BreadcrumbItem';
import BreadcrumbLink from '@/components/Common/Breadcrumbs/BreadcrumbLink';
import BreadcrumbRoot from '@/components/Common/Breadcrumbs/BreadcrumbRoot';
import BreadcrumbTruncatedItem from '@/components/Common/Breadcrumbs/BreadcrumbTruncatedItem';
import type { FormattedMessage } from '@/types';

type BreadcrumbLink = {
label: string;
label: FormattedMessage;
href: LinkProps['href'];
};

Expand Down Expand Up @@ -38,7 +39,7 @@ const Breadcrumbs: FC<BreadcrumbsProps> = ({

return (
<BreadcrumbItem
key={link.href.toString()}
key={link.label.toString()}
hidden={hidden}
hideSeparator={isLastItem}
position={position + +!hideHome}
Expand Down
16 changes: 12 additions & 4 deletions components/Common/MetaBar/index.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
.wrapper {
@apply flex
w-80
flex-col
items-start
gap-8
border-l
border-neutral-200
p-6
dark:border-neutral-900;
border-l-neutral-200
px-4
py-6
dark:border-l-neutral-900
md:max-w-xs
lg:px-6
xs:mt-8
xs:w-full
xs:border-l-0
xs:border-t
xs:border-t-neutral-200
xs:dark:border-t-neutral-900;

dt {
@apply mb-2
Expand Down
17 changes: 8 additions & 9 deletions components/Common/MetaBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ type MetaBarProps = {
items: Record<string, React.ReactNode>;
headings?: {
items: Heading[];
depth?: number;
minDepth?: number;
};
};

const MetaBar: FC<MetaBarProps> = ({ items, headings }) => {
const t = useTranslations();

// The default depth of headings to display in the table of contents.
const { depth = 2, items: headingItems = [] } = headings || {};
const { minDepth = 2, items: headingItems = [] } = headings || {};

const heading = useMemo(
() => headingItems.filter(head => head.depth === depth),
[depth, headingItems]
() => headingItems.filter(({ depth }) => depth >= minDepth && depth <= 4),
[minDepth, headingItems]
);

return (
Expand All @@ -35,21 +35,20 @@ const MetaBar: FC<MetaBarProps> = ({ items, headings }) => {
<dd>{value}</dd>
</Fragment>
))}

{heading.length > 0 && (
<Fragment key="tableOfContents">
<>
<dt>{t('components.metabar.tableOfContents')}</dt>
<dd>
<ol>
{heading.map(head => (
<li key={head.value}>
<Link href={`#${head?.data?.id || head.value}`}>
{head.value}
</Link>
<Link href={`#${head?.data?.id}`}>{head.value}</Link>
</li>
))}
</ol>
</dd>
</Fragment>
</>
)}
</dl>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

import NavItem from '@/components/Containers/NavItem';
import NavItem from '@/components/Common/NavItem';

type Story = StoryObj<typeof NavItem>;
type Meta = MetaObj<typeof NavItem>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const NavItem: FC<PropsWithChildren<NavItemProps>> = ({
href={href}
className={classNames(styles.navItem, styles[type], className)}
activeClassName={styles.active}
allowSubPath
>
<span className={styles.label}>{children}</span>
{showIcon && <ArrowUpRightIcon className={styles.icon} />}
Expand Down
9 changes: 7 additions & 2 deletions components/Common/Select/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
gap-1.5;

.label {
@apply text-sm
@apply block
w-full
text-sm
font-medium
text-neutral-800
dark:text-neutral-200;
}

.trigger {
@apply inline-flex
h-11
w-full
min-w-[17rem]
items-center
justify-between
Expand Down Expand Up @@ -97,7 +101,8 @@

.inline {
.trigger {
@apply min-w-fit
@apply h-auto
min-w-fit
px-2.5
py-2
text-sm
Expand Down
Loading
Loading