Skip to content

Commit

Permalink
Merge branch 'master' into feat/home
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/App.tsx
#	src/hooks/usePlaylist.ts
#	src/providers/QueryProvider.tsx
#	src/screens/Home/Home.module.scss
#	src/screens/Home/Home.tsx
  • Loading branch information
royschut committed May 4, 2021
2 parents 58b12ad + 3a17235 commit 2ccf363
Show file tree
Hide file tree
Showing 54 changed files with 1,578 additions and 93 deletions.
11 changes: 10 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const {
transform,
...rest
} = require('@snowpack/app-scripts-react/jest.config.js')();

module.exports = {
...require('@snowpack/app-scripts-react/jest.config.js')(),
transform: {
'.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform',
...transform,
},
...rest,
};
20 changes: 9 additions & 11 deletions lighthouserc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
module.exports = {
ci: {
collect: {
url : [
'http://127.0.0.1:4000'
],
startServerCommand : 'http-server ./build -p 4000 -g',
url: ['http://127.0.0.1:4000'],
startServerCommand: 'http-server ./build -p 4000 -g',
startServerReadyPattern: 'Available on',
numberOfRuns : 1
numberOfRuns: 1,
},
upload : {
'target': 'temporary-public-storage'
upload: {
target: 'temporary-public-storage',
},
assert : {
'preset': 'lighthouse:recommended',
}
}
assert: {
preset: 'lighthouse:no-pwa',
},
},
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@types/jest": "^26.0.22",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@types/react-router-dom": "^5.1.7",
"@types/snowpack-env": "^2.3.3",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
Expand All @@ -58,6 +59,7 @@
"eslint-watch": "^7.0.0",
"husky": "^6.0.0",
"jest": "^26.6.3",
"jest-css-modules-transform": "^4.2.1",
"lint-staged": "^10.5.4",
"postcss": "^8.2.10",
"postcss-cli": "^8.3.1",
Expand Down
4 changes: 0 additions & 4 deletions scripts/blueprint/base/Base.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
@use '../../styles/variables';
@use '../../styles/theme';

.basis {
// component styling
}
11 changes: 6 additions & 5 deletions scripts/blueprint/base/Base.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { render } from '@testing-library/react';

import Base from './Base';

describe('Base Component tests', () => {
test('dummy test', () => {
render(<Base></Base>);
expect(screen.getByText('hello world')).toBeInTheDocument();
describe('<Base>', () => {
test('renders and matches snapshot', () => {
const { container } = render(<Base />);

expect(container).toMatchSnapshot();
});
});
11 changes: 5 additions & 6 deletions scripts/blueprint/base/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import React from 'react';

import styles from './Base.module.scss';

type BaseProps = {
dummy?: string;
type Props = {
prop?: string;
};

const Base: React.FC<BaseProps> = ({ dummy = 'defaultValue' }: BaseProps) => {
const Base: React.FC<Props> = ({ prop }: Props) => {
return (
<div className={styles['base']}>
<p>hello world</p>
<p>{dummy}</p>
<div className={styles.base}>
<p>{prop}</p>
</div>
);
};
Expand Down
44 changes: 28 additions & 16 deletions snowpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
mount : {
mount: {
public: { url: '/', static: true },
src : { url: '/dist' },
src: { url: '/dist' },
},
plugins : [
alias: {
'@components': './src/components/*',
'@container': './src/container/*',
'@types': './src/types/*',
'@app': './src/*',
},
plugins: [
'@snowpack/plugin-postcss',
'@snowpack/plugin-react-refresh',
'@snowpack/plugin-dotenv',
Expand All @@ -16,30 +22,36 @@ module.exports = {
...(process.versions.pnp ? { tsc: 'yarn pnpify tsc' } : {}),
},
],
['@snowpack/plugin-run-script', {
name : 'eslint',
cmd : 'eslint src --ext .js,.jsx,.ts,.tsx',
watch: 'esw -w --clear src --ext .js,.jsx,.ts,.tsx'
}],
['@snowpack/plugin-run-script', {
name: 'stylelint',
cmd : 'stylelint src/**/*.scss'
}],
[
'@snowpack/plugin-run-script',
{
name: 'eslint',
cmd: 'eslint src --ext .js,.jsx,.ts,.tsx',
watch: 'esw -w --clear src --ext .js,.jsx,.ts,.tsx',
},
],
[
'@snowpack/plugin-run-script',
{
name: 'stylelint',
cmd: 'stylelint src/**/*.scss',
},
],
],
routes : [
routes: [
/* Enable an SPA Fallback in development: */
],
optimize : {
optimize: {
/* Example: Bundle your final build: */
// "bundle": true,
},
packageOptions: {
/* ... */
},
devOptions : {
devOptions: {
/* ... */
},
buildOptions : {
buildOptions: {
/* ... */
},
};
50 changes: 32 additions & 18 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
import React from 'react';
import React, { Component } from 'react';
import { BrowserRouter as Router } from 'react-router-dom';

import QueryProvider from './providers/QueryProvider';
import Root from './components/Root/Root';
import ConfigProvider from './providers/configProvider';
import Home from './screens/Home/Home';

import QueryProvider from './providers/QueryProvider';
import './styles/main.scss';

function App() {
return (
<ConfigProvider
configLocation={window.configLocation}
onLoading={(isLoading: boolean) =>
console.info(`Loading config: ${isLoading}`)
}
onValidationError={(error: Error) => console.error(`Config ${error}`)}
>
interface State {
error: Error | null;
}

class App extends Component {
public state: State = {
error: null,
};

componentDidCatch(error: Error) {
this.setState({ error });
}

render() {
return (
<QueryProvider>
<div className="App">
<Home />
</div>
<ConfigProvider
configLocation={window.configLocation}
onLoading={(isLoading: boolean) =>
console.info(`Loading config: ${isLoading}`)
}
onValidationError={(error: Error) => console.error(`Config ${error}`)}
>
<Router>
<Root error={this.state.error} />
</Router>
</ConfigProvider>
</QueryProvider>
</ConfigProvider>
);
);
}
}

export default App;
52 changes: 52 additions & 0 deletions src/components/ButtonLink/ButtonLink.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@use '../../styles/variables';
@use '../../styles/theme';
@use '../../styles/mixins/responsive';
@use '../../styles/mixins/utils';

//
// Navigation Button
// --------------------------------

.link {
position: relative;
display: inline-flex;
justify-content: inherit;
align-items: center;
min-height: 38px;
padding: 0 10px;
color: inherit;
font-family: theme.$body-alt-font-family;
font-weight: 700;
text-align: center;
text-decoration: none;
background: transparent;
border-radius: 4px;
cursor: pointer;
opacity: 0.7;
transition: background 0.1s ease, transform 0.1s ease;

@media (hover: hover) and (pointer: fine) {
&:hover,
&:active {
z-index: 1;
background: rgba(variables.$black, 0.7);
transform: scale(1.1);
opacity: 1;
}
}
}

.active {
color: variables.$white;
opacity: 1;
}

//
// mediaQueries
// --------------------------------

@include responsive.mobile-and-tablet() {
.link {
padding: 12px;
}
}
18 changes: 18 additions & 0 deletions src/components/ButtonLink/ButtonLink.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

import { render } from '../../testUtils';

import ButtonLink from './ButtonLink';

describe('<ButtonLink />', () => {
test('renders link with route label', () => {
const { getByText } = render(<ButtonLink label="home" to="/" />);
expect(getByText(/home/i)).toBeTruthy();
});

it('renders and matches snapshot', () => {
const { container } = render(<ButtonLink label="home" to="/" />);

expect(container).toMatchSnapshot();
});
});
24 changes: 24 additions & 0 deletions src/components/ButtonLink/ButtonLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { NavLink } from 'react-router-dom';

import styles from './ButtonLink.module.scss';

type Props = {
label: string;
to: string;
};

const ButtonLink: React.FC<Props> = ({ label, to }) => {
return (
<NavLink
className={styles.link}
activeClassName={styles.active}
to={to}
exact
>
<span className={styles.buttonLabel}>{label}</span>
</NavLink>
);
};

export default ButtonLink;
15 changes: 15 additions & 0 deletions src/components/ButtonLink/__snapshots__/ButtonLink.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ButtonLink /> renders and matches snapshot 1`] = `
<div>
<a
aria-current="page"
class="link active"
href="/"
>
<span>
home
</span>
</a>
</div>
`;
Loading

0 comments on commit 2ccf363

Please sign in to comment.