Skip to content

Commit

Permalink
boilerplate updated
Browse files Browse the repository at this point in the history
  • Loading branch information
lipex360x committed Sep 19, 2022
1 parent 3ba06bc commit 9148b7f
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 46 deletions.
9 changes: 2 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@
"@typescript-eslint/no-non-null-assertion": "off",

"import-helpers/order-imports": ["error", {
"newlinesBetween": "never",
"newlinesBetween": "always",
"groups": [
"absolute",
"module",
"/^react/",
"/^@/components/",
"/^@/constants/",
"/^@/services/",
"/^@/store/",
"/^@/styles/",
"/^@/",
"index"
],
"alphabetize": { "order": "asc", "ignoreCase": true }
Expand Down
6 changes: 2 additions & 4 deletions generators/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ module.exports = {

actions: (data) => {
const pathTemplate = "./pages/templates";
const pagePath = "../src/pages/{{pageName}}Page";
const pagePath = "../src/pages/{{pageName}}";

const files = () => {
const arrayFiles = [];

arrayFiles.push(pushFiles(pagePath, "index.ts", "index.hbs"));
arrayFiles.push(pushFiles(pagePath, "styles.ts", "styles.hbs"));
arrayFiles.push(pushFiles(pagePath, "{{pageName}}Page.tsx", "page.hbs"));
arrayFiles.push(pushFiles(pagePath, "{{pageName}}.tsx", "page.hbs"));

return arrayFiles;
};
Expand Down
1 change: 0 additions & 1 deletion generators/pages/templates/index.hbs

This file was deleted.

14 changes: 9 additions & 5 deletions generators/pages/templates/page.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as S from './styles'
import Head from 'next/head'

export const {{pageName}}Page = () => {
export default function {{pageName}}() {
return (
<S.Wrapper>
<span>Hello {{pageName}}Page</span>
</S.Wrapper>
<>
<Head>
<title>{{pageName}}</title>
</Head>

<h1>Hello {{pageName}}</h1>
</>
)
}
5 changes: 0 additions & 5 deletions generators/pages/templates/styles.hbs

This file was deleted.

1 change: 1 addition & 0 deletions src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios'

import { NEXT_URL } from '@/constants/environment'

export const api = axios.create({
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ButtonHTMLAttributes, ForwardRefRenderFunction } from 'react'

import * as S from './styles'

type ButtonsTypes = ButtonHTMLAttributes<HTMLButtonElement>
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/Button/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled, { css, DefaultTheme } from 'styled-components'

import { ButtonProps } from './Button'

export type WrapperProps = {
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/FormElements/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { InputHTMLAttributes, useState } from 'react'

import * as S from './styles'

export type CheckboxProps = {
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/FormElements/TextField/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { forwardRef, InputHTMLAttributes } from 'react'

import * as S from './styles'

type TextFieldProps = {
Expand Down
1 change: 1 addition & 0 deletions src/components/bosons/FormContainer/FormContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ReactNode } from 'react'

import * as S from './styles'

export type FormContainerProps = {
Expand Down
7 changes: 4 additions & 3 deletions src/components/organisms/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Button } from '@/components/atoms/Button'
import { Minus, Plus, ReturnCircled } from '@/components/atoms/Icons'
import { Logo } from '@/components/atoms/Logo/Logo'
import toastService from '@/services/toast.service'
import { useZustand } from '@/store/useZustand'
import { toastService } from '@/services/'
import { zustandStore } from '@/store'

import * as S from './styles'

export const HomePage = () => {
const { count, increment, decrement, reset } = useZustand()
const { count, increment, decrement, reset } = zustandStore()

const handleReset = () => {
toastService.success('Store Count reseted')
Expand Down
1 change: 1 addition & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AppProps } from 'next/app'
import { ThemeProvider } from 'styled-components'

import { DefaultLayout } from '@/components/templates/DefaultLayout/'
import GlobalStyles from '@/styles/global'
import theme from '@/styles/theme'
Expand Down
3 changes: 3 additions & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * as toastService from './toast.service'
export * as priceService from './price.service'
export * as localStorageService from './localStorage.service'
22 changes: 22 additions & 0 deletions src/services/localStorage.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const setItem = (key: string, item: string | object) => {
const value = typeof item === 'object' ? JSON.stringify(item) : item
return window.localStorage.setItem(key, value)
}

export const getItem = (key: string) => {
const value = window.localStorage.getItem(key)

if (!value) {
return
}

try {
return JSON.parse(value)
} catch {
return value
}
}

export const removeItem = (key: string) => {
return window.localStorage.removeItem(key)
}
6 changes: 6 additions & 0 deletions src/services/price.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const priceFormat = (price: number) => {
return new Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL',
}).format(price)
}
18 changes: 5 additions & 13 deletions src/services/toast.service.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { toast } from 'react-hot-toast'

const success = (content: string) => {
export const success = (content: string) => {
return toast.success(content)
}

const error = (content: string) => {
export const error = (content: string) => {
return toast.error(content)
}

const loading = (content: string) => {
export const loading = (content: string) => {
return toast.loading(content)
}

const dismiss = () => {
export const dismiss = () => {
toast.dismiss()
}

const promise = (
export const promise = (
promise: Promise<any>,
content: string,
success: string,
Expand All @@ -28,11 +28,3 @@ const promise = (
error,
})
}

export default {
success,
error,
loading,
dismiss,
promise,
}
1 change: 1 addition & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { zustandStore } from './zustand.store'
4 changes: 2 additions & 2 deletions src/store/useZustand.ts → src/store/zustand.store.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { produce } from 'immer'
import create from 'zustand'

export type UseZustandProps = {
export type ZustandStoreProps = {
count: number
increment: () => void
decrement: () => void
reset: () => void
}

export const useZustand = create<UseZustandProps>((set) => ({
export const zustandStore = create<ZustandStoreProps>((set) => ({
count: 0,

increment: () =>
Expand Down
6 changes: 0 additions & 6 deletions src/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ const GlobalStyles = createGlobalStyle`
button {
cursor: pointer;
}
body {
font-family: 'Roboto';
font-size: ${theme.font.size.medium};
color: ${theme.color.black};
}
`}
`

Expand Down

0 comments on commit 9148b7f

Please sign in to comment.