Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
fa4424f
move console run into consoleCalculator.ts
Apr 2, 2023
3be0348
update script
Apr 2, 2023
7efe286
add react to webpack
Apr 2, 2023
ac2527d
add storybook
Apr 2, 2023
3bec9a5
update storybook default files by eslint
Apr 2, 2023
03e07df
add eslint plugins
Apr 2, 2023
d7981e6
add jest coverage
Apr 2, 2023
7a88044
add tests for full coverage
Apr 2, 2023
cc2d6a9
Merge branch 'master' into second-dz-add-react-components-to-calculator
Apr 18, 2023
f31f888
add coverage
Apr 18, 2023
8707d53
add Calculator.tsx
Apr 18, 2023
c94659a
add Calculator.stories.tsx
Apr 18, 2023
52f2f9f
add Button.tsx
Apr 18, 2023
e59127b
add click
Apr 18, 2023
a7a9261
update config quotes
Apr 19, 2023
61c0360
save changes
May 21, 2023
87a3aea
add alert for number
May 21, 2023
f8b82b0
fix quotes in style
May 21, 2023
3abeef0
add component with state
May 25, 2023
e36fa27
save progress
Jun 13, 2023
c1d1752
add coverage to gitignore
Jun 13, 2023
76aad53
add idea to gitignore
Jun 13, 2023
69c7450
add coverage badger
Jun 13, 2023
849babe
add coverage badger in pull request
Jun 13, 2023
9f92f87
update request template
Jun 13, 2023
caee369
add badge
Jun 13, 2023
3308147
update badge
Jun 13, 2023
4beabda
update node yml
Jun 13, 2023
6fa9a3f
up
Jun 13, 2023
3e27944
up
Jun 13, 2023
73265e2
up
Jun 13, 2023
2e4f913
up
Jun 13, 2023
f4325ad
up
Jun 13, 2023
d223405
up
Jun 13, 2023
9af9c4c
up
Jun 13, 2023
98fda37
up
Jun 13, 2023
7784d67
up
Jun 13, 2023
c307038
up
Jun 13, 2023
c1d9fb7
up
Jun 13, 2023
e00f93f
up
Jun 13, 2023
ae047e2
up
Jun 13, 2023
94f31ff
up
Jun 13, 2023
703d0fe
up
Jun 13, 2023
7c821ba
up
Jun 13, 2023
71fe81f
Merge branch 'master' into second-dz-add-react-components-to-calculator
Jun 13, 2023
c041fe3
up
Jun 13, 2023
4699678
up
Jun 13, 2023
a843f72
up
Jun 13, 2023
21b3dbb
up
Jun 13, 2023
47bb174
up
Jun 13, 2023
2546942
up
Jun 13, 2023
a8c9502
up
Jun 13, 2023
cea7a67
up
Jun 13, 2023
d74a9f9
up
Jun 13, 2023
336dddb
up
Jun 13, 2023
b078d70
up
Jun 13, 2023
7847e0e
add react testing library
Jun 14, 2023
70dbaca
add Calculator snapshot
Jun 14, 2023
2543f61
add snapshots
Jun 14, 2023
609fc40
add Calculator test
Jun 14, 2023
c37ec48
add Button test
Jun 14, 2023
a2a1cfb
add build
Jun 14, 2023
af5fec5
add chromatic
Jun 14, 2023
cc9990f
add files
Jun 14, 2023
46d696d
Merge branch 'second-dz-add-react-components-to-calculator' into dz-c…
Jun 15, 2023
a546ae7
add state counter
Jun 15, 2023
e408942
add todos
Jun 15, 2023
f3ed45f
add handle click
Jun 15, 2023
56a60b3
add stories
Jun 15, 2023
31488c9
add components
Jun 19, 2023
557e3f0
refactor: send function
Jun 20, 2023
dee1698
create data file loader
Jun 21, 2023
410828a
add fix by comments
Jun 21, 2023
b96c4d1
add clover.xml
Jun 21, 2023
3d7db4c
update docs
Jun 21, 2023
efd71ce
Merge branch 'dz-lesson-16' into dz-lesson-18-patterns
Jun 21, 2023
9cef8e3
show xhprof & tools
Jun 21, 2023
a031006
move to scale change
Jun 22, 2023
31025e1
update scale
Jun 22, 2023
869efd1
update type
Jun 25, 2023
9b441d3
save changes
Jul 3, 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
17 changes: 13 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"parser": "flow",
"printWidth": 80,
"tabWidth": 4,
"useTabs": false
"useTabs": false,
"jsxSingleQuote": true
}
],
"@typescript-eslint/quotes": [
Expand All @@ -23,9 +24,17 @@
}
],
"@typescript-eslint/no-inferrable-types": 0,

"indent": ["error", 4, {"SwitchCase": 1}]

"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"jsx-quotes": [
"error",
"prefer-single"
]
},
"parserOptions": {
"sourceType": "module",
Expand Down
35 changes: 33 additions & 2 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy Jekyll with GitHub Pages dependencies preinstalled
on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
branches: ["master", "second-dz-add-react-components-to-calculator", "dz-lesson-16"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -22,9 +22,21 @@ concurrency:
cancel-in-progress: false

jobs:

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Install
run: npm install
- name: Test and Coverage
run: npm run coverage

# Build job
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -33,7 +45,7 @@ jobs:
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
source: ./docs
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
Expand All @@ -49,3 +61,22 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

badge:
runs-on: ubuntu-latest
needs: deploy
steps:
# Your original steps
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Install
run: npm install
- name: Test and Coverage
run: npm run coverage

# Add this
- name: Update Coverage Badge
# GitHub actions: default branch variable
# https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable
# if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: we-cli/coverage-badge-action@main
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.vscode
node_modules
dist
/coverage/
.idea
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
15 changes: 15 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
"stories": [
"../src/Components/*.stories.mdx",
"../src/Components/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions"
],
"framework": "@storybook/react",
"core": {
"builder": "@storybook/builder-webpack5"
}
}
9 changes: 9 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
42 changes: 42 additions & 0 deletions Components_storybook_original/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';

import { Button } from './Button';

// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
title: 'Example/Button',
component: Button,
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
backgroundColor: { control: 'color' },
},
// eslint-disable-next-line prettier/prettier
} as ComponentMeta<typeof Button>;

// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;

export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/react/writing-stories/args
Primary.args = {
primary: true,
label: 'Button',
};

export const Secondary = Template.bind({});
Secondary.args = {
label: 'Button',
};

export const Large = Template.bind({});
Large.args = {
size: 'large',
label: 'Button',
};

export const Small = Template.bind({});
Small.args = {
size: 'small',
label: 'Button',
};
54 changes: 54 additions & 0 deletions Components_storybook_original/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import './button.css';

interface ButtonProps {
/**
* Is this the principal call to action on the page?
*/
primary?: boolean;
/**
* What background color to use
*/
backgroundColor?: string;
/**
* How large should the button be?
*/
size?: 'small' | 'medium' | 'large';
/**
* Button contents
*/
label: string;
/**
* Optional click handler
*/
onClick?: () => void;
}

/**
* Primary UI component for user interaction
*/
export const Button = ({
primary = false,
size = 'medium',
backgroundColor,
label,
...props
}: ButtonProps) => {
const mode = primary
? 'storybook-button--primary'
: 'storybook-button--secondary';
return (
<button
type="button"
className={[
'storybook-button',
`storybook-button--${size}`,
mode,
].join(' ')}
style={{ backgroundColor }}
{...props}
>
{label}
</button>
);
};
39 changes: 39 additions & 0 deletions Components_storybook_original/Calculator.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { Calculator } from './Calculator';



export default {
title: 'Calculator',
component: Calculator,
argTypes: {
backgroundColor: { control: 'color' },
},
// eslint-disable-next-line prettier/prettier
} as ComponentMeta<typeof Calculator>;

const Template: ComponentStory<typeof Calculator> = (args) => <Calculator/>;

export const Primary = Template.bind({});
Primary.args = {
primary: true,
label: 'Calculator',
};

// export const Secondary = Template.bind({});
// Secondary.args = {
// label: 'Button',
// };
//
// export const Large = Template.bind({});
// Large.args = {
// size: 'large',
// label: 'Button',
// };
//
// export const Small = Template.bind({});
// Small.args = {
// size: 'small',
// label: 'Button',
// };
19 changes: 19 additions & 0 deletions Components_storybook_original/Calculator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';

export const Calculator = () => {

return (
<div>
<div className="status">{status}</div>
<div className="board-row">
первая строка цифр
</div>
<div className="board-row">
вторая строка цифр
</div>
<div className="board-row">
третья строка цифр
</div>
</div>
);
};
26 changes: 26 additions & 0 deletions Components_storybook_original/Header.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';

import { Header } from './Header';

export default {
title: 'Example/Header',
component: Header,
parameters: {
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
layout: 'fullscreen',
},
// eslint-disable-next-line prettier/prettier
} as ComponentMeta<typeof Header>;

const Template: ComponentStory<typeof Header> = (args) => <Header {...args} />;

export const LoggedIn = Template.bind({});
LoggedIn.args = {
user: {
name: 'Jane Doe',
},
};

export const LoggedOut = Template.bind({});
LoggedOut.args = {};
75 changes: 75 additions & 0 deletions Components_storybook_original/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from 'react';

import { Button } from './Button';
import './header.css';

type User = {
name: string,
};

interface HeaderProps {
user?: User;
onLogin: () => void;
onLogout: () => void;
onCreateAccount: () => void;
}

export const Header = ({
user,
onLogin,
onLogout,
onCreateAccount,
}: HeaderProps) => (
<header>
<div className="wrapper">
<div>
<svg
width="32"
height="32"
viewBox="0 0 32 32"
xmlns="http://www.w3.org/2000/svg"
>
<g fill="none" fillRule="evenodd">
<path
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
fill="#FFF"
/>
<path
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
fill="#555AB9"
/>
<path
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
fill="#91BAF8"
/>
</g>
</svg>
<h1>Acme</h1>
</div>
<div>
{user ? (
<>
<span className="welcome">
Welcome, <b>{user.name}</b>!
</span>
<Button
size="small"
onClick={onLogout}
label="Log out"
/>
</>
) : (
<>
<Button size="small" onClick={onLogin} label="Log in" />
<Button
primary
size="small"
onClick={onCreateAccount}
label="Sign up"
/>
</>
)}
</div>
</div>
</header>
);
Loading