Skip to content

Commit

Permalink
#8 - feat: add page component
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jan 9, 2024
1 parent 46b9052 commit b8b962a
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<style>
html,
body,
#storybook-root {
height: 100%;
margin: 0;
}
</style>
8 changes: 4 additions & 4 deletions bin/create_component.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function create_index_file() {

# Function to create the CSS file
function create_css_file() {
echo ".mykn-$component_name_lowercase {" > "$2/$component_name_lowercase.css"
echo " /* Rules here. */" >> "$2/$component_name_lowercase.css"
echo "}" >> "$2/$component_name_lowercase.css"
echo ".mykn-$component_name_lowercase {" > "$2/$component_name_lowercase.scss"
echo " /* Rules here. */" >> "$2/$component_name_lowercase.scss"
echo "}" >> "$2/$component_name_lowercase.scss"
}

# Function to create the stories.tsx file
Expand Down Expand Up @@ -60,7 +60,7 @@ function create_component_file() {
cat > "$2/$component_name_lowercase.tsx" <<EOF
import React from "react";
import "./$component_name_lowercase.css";
import "./$component_name_lowercase.scss";
export type ${capitalized_component_name}Props = React.PropsWithChildren<{
// Props here.
Expand Down
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Auto-generated file. Do not modify manually.
export * from "./layout";
export * from "./logo";
export * from "./page";
2 changes: 1 addition & 1 deletion src/components/layout/container/container.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.mykn-container {
margin: 0 auto;
max-width: min(1240px, calc(100% - 40px));
max-width: 1240px;
width: 100%;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/logo/logo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ type Story = StoryObj<typeof meta>;
export const LogoComponent: Story = {
args: {
href: "/?path=/story/brand-logo--logo-component",
hrefLabel: "Navigate to logo component page.",
hrefLabel: "Navigate to story page",
label: "Maykin logo",
},
};

export const LogoAnimatesOnHoverAndClick: Story = {
args: {
href: "/?path=/story/brand-logo--logo-component",
hrefLabel: "Navigate to logo component page.",
hrefLabel: "Navigate to story page",
label: "Maykin logo",
},
play: async () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/page/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./page";
9 changes: 9 additions & 0 deletions src/components/page/page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import "../../settings/style";

.mykn-page {
background-color: var(--theme-color-primary-200);
box-sizing: border-box;
width: 100%;
height: 100%;
padding: 50px 20px;
}
42 changes: 42 additions & 0 deletions src/components/page/page.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Meta, StoryObj } from "@storybook/react";
import React from "react";

import { Container, Grid } from "../layout";
import { Column } from "../layout/column";
import { Logo } from "../logo";
import { Page } from "./page";

const meta = {
title: "Building Blocks/Page",
component: Page,
parameters: {
layout: "fullscreen",
},
} satisfies Meta<typeof Page>;

export default meta;
type Story = StoryObj<typeof meta>;

export const PageComponent: Story = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
},
};

export const SamplePage: Story = {
args: {
children: (
<Container>
<Grid>
<Column span={12}>
<Logo
href="/?path=/story/building-blocks-page--sample-page"
hrefLabel="Navigate to story page"
label="Maykin"
/>
</Column>
</Grid>
</Container>
),
},
};
19 changes: 19 additions & 0 deletions src/components/page/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";

import "./page.scss";

export type PageProps = React.PropsWithChildren<{
// Props here.
}>;

/**
* Provides the base theme for a page.
* @param children
* @param props
* @constructor
*/
export const Page: React.FC<PageProps> = ({ children, ...props }) => (
<div className="mykn-page" {...props}>
{children}
</div>
);
1 change: 1 addition & 0 deletions src/settings/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $breakpoint-desktop: 768px;
--theme-color-primary-700: #5422B9;
--theme-color-primary-600: #8D75E6;
--theme-color-primary-400: #BDB0ED;
--theme-color-primary-200: #ECF1FF; /* FIXME? */

--theme-shade-800: #0F172A;
--theme-shade-700: #1E293B;
Expand Down

0 comments on commit b8b962a

Please sign in to comment.