Skip to content

Commit

Permalink
shared module
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestofreyreg committed Nov 23, 2020
1 parent 57e9896 commit 960d79a
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
out/
.next/
node_modules/
next-env.d.ts
next-env.d.ts
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"test": "jest --coverage",
"storybook": "start-storybook -p 6006"
"storybook": "start-storybook -p 6006",
"lint": "eslint --ext .ts,.tsx,.js packages"
},
"keywords": [],
"author": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import initStoryshots from '@storybook/addon-storyshots'

initStoryshots()

1 change: 0 additions & 1 deletion packages/app/template/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ module.exports = withBundleAnalyzer(
basePath: '/template'
})
)

3 changes: 3 additions & 0 deletions packages/app/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
},
"author": "",
"license": "ISC",
"dependencies": {
"@outsrc/functions": "0.0.0"
},
"devDependencies": {
"@storybook/react": "^6.1.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ test('loads and displays greeting', async () => {

expect(screen.getByTestId('button')).toHaveTextContent('Click Here')
})

1 change: 0 additions & 1 deletion packages/app/template/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ export const Button: React.FC<ButtonProps> = ({ label, onClick }) => {
</button>
)
}

1 change: 0 additions & 1 deletion packages/app/template/src/components/Button/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './Button'

6 changes: 3 additions & 3 deletions packages/app/template/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as React from 'react'
import { NextPage } from 'next'
import { Button } from 'components/Button'
import { capitalize } from '@outsrc/functions'

const Index: NextPage = () => {
const handleClick = () => {
const handleClick = (): void => {
alert('World')
}

return (
<div>
<Button label='Hello template' onClick={handleClick} />
<Button label={capitalize('hello template')} onClick={handleClick} />
</div>
)
}

export default Index

12 changes: 12 additions & 0 deletions packages/shared/functions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@outsrc/functions",
"version": "0.0.0",
"description": "Templated shared functions",
"main": "src/index.ts",
"scripts": {
"test": "jest --coverage --config ../../../jest.config.js ./src/*"
},
"keywords": [],
"author": "",
"license": "ISC"
}
7 changes: 7 additions & 0 deletions packages/shared/functions/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { capitalize } from './index'

describe('Functions', () => {
it('capitalize', () => {
expect(capitalize('john doe')).toBe('John Doe')
})
})
5 changes: 5 additions & 0 deletions packages/shared/functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const capitalize = (a: string): string =>
a
.split(' ')
.map(p => p[0].toUpperCase() + p.substr(1).toLocaleLowerCase())
.join(' ')
8 changes: 8 additions & 0 deletions packages/shared/functions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../../config/next.tsconfig.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"baseUrl": "./src"
},
"exclude": ["node_modules"]
}

0 comments on commit 960d79a

Please sign in to comment.