-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from maykinmedia/construction
Construction
- Loading branch information
Showing
40 changed files
with
28,823 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"ignorePatterns": [ | ||
"*.js", | ||
"*.config.js", | ||
"dist/**/*", | ||
"**/*.css", | ||
"**/*.scss", | ||
"**/*.md" | ||
], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:react/recommended", | ||
"plugin:prettier/recommended", | ||
"plugin:storybook/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"react" | ||
], | ||
"rules": { | ||
"react/react-in-jsx-scope": "off" | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
*storybook.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
cd frontend | ||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": ["@trivago/prettier-plugin-sort-imports"], | ||
"importOrder": ["^lib/(.*)$", "^components/(.*)$", "^[./]"], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { StoryContext, StoryFn } from "@storybook/react"; | ||
import * as React from "react"; | ||
import { RouterProvider, createBrowserRouter } from "react-router-dom"; | ||
|
||
import App from "../src/App"; | ||
|
||
/** | ||
* Decorators providing React Router integration (RouterProvider), optionally: when using this decorator a parameter | ||
* "loader" can be specified providing React Router `LoaderFunction` for this `StoryFn`. | ||
*/ | ||
export const ReactRouterDecorator = ( | ||
Story: StoryFn, | ||
{ parameters }: StoryContext, | ||
) => { | ||
const router = createBrowserRouter([ | ||
{ | ||
path: "*", | ||
element: <Story />, | ||
loader: parameters.loader, | ||
}, | ||
]); | ||
|
||
return ( | ||
<App> | ||
<RouterProvider router={router} /> | ||
</App> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { StorybookConfig } from "@storybook/react-webpack5"; | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: [ | ||
"@storybook/preset-create-react-app", | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@chromatic-com/storybook", | ||
"@storybook/addon-interactions", | ||
], | ||
framework: { | ||
name: "@storybook/react-webpack5", | ||
options: {}, | ||
}, | ||
core: { | ||
disableTelemetry: true, // 👈 Disables telemetry | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
staticDirs: ["../public"], | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<style> | ||
html, | ||
body, | ||
.sb-show-main, | ||
#storybook-root { | ||
height: 100%; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
} | ||
|
||
.sb-show-main { | ||
padding: 0!important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Preview } from "@storybook/react"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/bin/bash | ||
|
||
PAGES_DIR="src/pages" | ||
INDEX_FILE="$PAGES_DIR/index.ts" | ||
|
||
page_name=$1 | ||
page_name_lowercase=$(echo "$page_name" | tr '[:upper:]' '[:lower:]') | ||
capitalized_page_name=$(echo "$page_name" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}') | ||
page_dir="$PAGES_DIR/$page_name_lowercase" | ||
|
||
# Function to check if a directory exists | ||
function directory_exists() { | ||
[ -d $1 ] | ||
} | ||
|
||
# Function to create a directory if it doesn't exist | ||
function create_directory() { | ||
if ! directory_exists $1; then | ||
mkdir -p $1 | ||
fi | ||
} | ||
|
||
# Function to create the index.ts file | ||
function create_index_file() { | ||
echo "export * from \"./$capitalized_page_name\";" > "$2/index.ts" | ||
} | ||
|
||
# Function to create the CSS file | ||
function create_css_file() { | ||
echo ".${capitalized_page_name}Page {" > "$2/$capitalized_page_name.css" | ||
echo " /* Rules here. */" >> "$2/$capitalized_page_name.css" | ||
echo "}" >> "$2/$capitalized_page_name.css" | ||
} | ||
|
||
# Function to create the stories.tsx file | ||
function create_stories_file() { | ||
cat > "$2/$capitalized_page_name.stories.tsx" <<EOF | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { ${capitalized_page_name}Page } from "./$capitalized_page_name"; | ||
const meta: Meta<typeof ${capitalized_page_name}Page> = { | ||
title: "Pages/${capitalized_page_name}", | ||
component: ${capitalized_page_name}Page, | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
export const ${page_name_lowercase}Page: Story = { | ||
args: { | ||
children: "The quick brown fox jumps over the lazy dog.", | ||
}, | ||
}; | ||
EOF | ||
} | ||
|
||
# Function to create the page file | ||
function create_page_file() { | ||
cat > "$2/$capitalized_page_name.tsx" <<EOF | ||
import React from "react"; | ||
import "./$capitalized_page_name.css"; | ||
export type ${capitalized_page_name}Props = React.ComponentProps<"main"> & { | ||
// Props here. | ||
}; | ||
/** | ||
* ${capitalized_page_name} page | ||
*/ | ||
export function ${capitalized_page_name}Page({ children, ...props }: ${capitalized_page_name}Props) { | ||
return ( | ||
<main className="${capitalized_page_name}Page" {...props}> | ||
{children} | ||
</main> | ||
); | ||
} | ||
EOF | ||
} | ||
|
||
# Function to update the index.ts file in pages | ||
function update_index_file() { | ||
echo "// Auto-generated file. Do not modify manually." > "$INDEX_FILE" | ||
for page_dir in "$PAGES_DIR"/*/; do | ||
page_name=$(basename "$page_dir") | ||
echo "export * from \"./$page_name\";" >> "$INDEX_FILE" | ||
done | ||
} | ||
|
||
# Main script | ||
|
||
# Check if $PAGES_DIR directory exists, if not create it | ||
create_directory $PAGES_DIR | ||
|
||
# Check if a page name is provided | ||
if [ -z "$1" ]; then | ||
echo "Error: Please provide a page name." | ||
exit 1 | ||
fi | ||
|
||
# Check if page already exists | ||
if directory_exists $page_dir; then | ||
echo "Error: page '$capitalized_page_name' already exists." | ||
exit 1 | ||
fi | ||
|
||
# Create page directory | ||
create_directory $page_dir | ||
|
||
# Create individual files | ||
create_index_file $capitalized_page_name $page_dir | ||
create_css_file $capitalized_page_name $page_dir | ||
create_stories_file $capitalized_page_name $page_dir | ||
create_page_file $capitalized_page_name $page_dir | ||
|
||
# Update pages/index.ts file | ||
update_index_file | ||
|
||
echo "page '$capitalized_page_name' created successfully." |
Oops, something went wrong.