Skip to content

Added page (and base) style and root imports #4

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

Merged
merged 1 commit into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
plugins: [
'@babel/plugin-proposal-class-properties'
'@babel/plugin-proposal-class-properties',
['babel-plugin-root-import', {
"rootPathSuffix": "src/",
"rootPathPrefix": "@/"
}]
],
presets: [
'@babel/typescript',
Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^26.0.10",
"@types/react": "^16.9.46",
"@types/react-dom": "^16.9.8",
"@types/react-is": "^16.7.1",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"babel-plugin-root-import": "^6.6.0",
"dart-sass": "^1.25.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.3",
Expand Down
20 changes: 20 additions & 0 deletions src/components/Page/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import clsx from 'clsx';

type PageContentProps = React.HTMLAttributes<HTMLDivElement>;

const PageContent = ({
children,
className
}: React.PropsWithChildren<PageContentProps>): React.ReactElement => (
<div
className={clsx(
'page-content',
className
)}
>
{children}
</div>
);

export default PageContent;
34 changes: 34 additions & 0 deletions src/components/Page/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react';
import Panel from '@/components/Panel';
import clsx from 'clsx';

export interface PageHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
title?: string;
}

const PageHeader = ({
children,
className,
title
}: React.PropsWithChildren<PageHeaderProps>): React.ReactElement => (
<Panel
className={clsx(
'page-header',
title && 'with-title',
className
)}
>
{title && (
<div
className={clsx(
'page-header-title'
)}
>
<h1>{title}</h1>
</div>
)}
{children}
</Panel>
);

export default PageHeader;
25 changes: 25 additions & 0 deletions src/components/Page/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from 'react';
import clsx from 'clsx';
import PageHeader from '@/components/Page/Header';
import PageContent from '@/components/Page/Content';

export type PageProps = React.HTMLAttributes<HTMLDivElement> ;

const Page = ({
children,
className,
}: React.PropsWithChildren<PageProps>): React.ReactElement => (
<div
className={clsx(
'page',
className
)}
>
{children}
</div>
);

Page.Header = PageHeader;
Page.Content = PageContent;

export default Page;
24 changes: 24 additions & 0 deletions src/components/Panel/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as React from 'react';
import clsx from 'clsx';

interface PanelProps extends React.HTMLAttributes<HTMLDivElement> {
spaced?: boolean;
}

const Panel = ({
children,
className,
spaced
}: React.PropsWithChildren<PanelProps>): React.ReactElement => (
<div
className={clsx(
'panel',
spaced && 'panel-spaced',
className
)}
>
{children}
</div>
);

export default Panel;
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './utils';
export { default as Page } from './Page';
export { default as Panel } from './Panel';
Empty file.
Loading