Skip to content

Commit

Permalink
TG 1087 Maintenance - Migrating from Styled-Components to CSS Modules (
Browse files Browse the repository at this point in the history
…#38)

* Remove components boilerplate

* Remove common components

* TG-1099 Remove theme switch feature and remove all redux related dependencies

* TG-1097 Refactor all components to use css modules and remove styled-component dependency

* TG-1097 Add new css modules

* Restore project name and remove themed logos

* Fix next config and group imports

---------

Co-authored-by: Luca <[email protected]>
  • Loading branch information
lucaspinosi and Luca authored Jan 30, 2024
1 parent 414b79f commit ac3a0a0
Show file tree
Hide file tree
Showing 29 changed files with 88 additions and 910 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { expect } from '@jest/globals'
import { screen } from '@testing-library/react'
import { render, screen } from '@testing-library/react'
import React from 'react'

import { Navbar } from '@/components/Navbar'
import { renderWithWrappers } from '../functions'

const setup = () => renderWithWrappers(<Navbar />)

test('Navbar renders correctly', () => {
setup()
render(<Navbar />)
expect(screen.getByRole('img')).toBeTruthy()
})

This file was deleted.

24 changes: 0 additions & 24 deletions {{cookiecutter.project_dirname}}/__tests__/functions.tsx

This file was deleted.

22 changes: 9 additions & 13 deletions {{cookiecutter.project_dirname}}/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

const { withSentryConfig } = require('@sentry/nextjs')

const {
SENTRY_AUTH_TOKEN,
SENTRY_ORG,
SENTRY_PROJECT_NAME,
SENTRY_URL,
} = process.env
const { SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT_NAME, SENTRY_URL } =
process.env

const nextjsConfig = {
compiler: { styledComponents: true },
i18n:{
i18n: {
defaultLocale: 'en-US',
locales: ['en-US', 'it-IT'],
locales: ['en-US', 'it-IT']
},
output: 'standalone',
reactStrictMode: true,
Expand All @@ -22,7 +17,7 @@ const nextjsConfig = {
{
source: '/{{ cookiecutter.service_slug }}/health',
destination: '/api/health'
},
}
]
}

Expand All @@ -37,8 +32,9 @@ const SentryWebpackPluginOptions = {

// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
const config = SENTRY_AUTH_TOKEN && SENTRY_ORG && SENTRY_URL
? withSentryConfig(nextjsConfig, SentryWebpackPluginOptions)
: nextjsConfig
const config =
SENTRY_AUTH_TOKEN && SENTRY_ORG && SENTRY_URL
? withSentryConfig(nextjsConfig, SentryWebpackPluginOptions)
: nextjsConfig

module.exports = config
10 changes: 1 addition & 9 deletions {{cookiecutter.project_dirname}}/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@
},
"dependencies": {
"@next/font": "^13.4.19",
"@reduxjs/toolkit": "^1.9.5",
"@sentry/nextjs": "^7.64.0",
"basic-auth": "^2.0.1",
"express": "^4.18.2",
"next": "^13.4.19",
"nookies": "^2.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"react-redux": "^8.1.2",
"redux": "^4.2.1",
"styled-components": "^6.0.8",
"styled-normalize": "^8.0.7"
"react-is": "^18.2.0"
},
"devDependencies": {
"@next/eslint-plugin-next": "^13.4.19",
Expand All @@ -40,8 +34,6 @@
"@types/node": "^20.5.3",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/react-redux": "^7.1.26",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"eslint": "^8.48.0",
Expand Down
12 changes: 0 additions & 12 deletions {{cookiecutter.project_dirname}}/public/images/logo-dark.svg

This file was deleted.

12 changes: 0 additions & 12 deletions {{cookiecutter.project_dirname}}/public/images/logo-light.svg

This file was deleted.

23 changes: 4 additions & 19 deletions {{cookiecutter.project_dirname}}/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
import React from 'react'
import styled from 'styled-components'
import styles from '@/styles/navbar.module.css'

import { ThemeSwitch } from '@/components/ThemeSwitch'
import Image from 'next/image'
import { useAppSelector } from '@/store'

const Navbar = () => {
const theme = useAppSelector(state => state.utils.theme)

return (
<Nav>
<nav className={styles.navbar}>
<Image
src={`/images/logo-${theme}.svg`}
src={`/images/logo.svg`}
width='110'
height='48'
alt={'sito logo'}
/>
<ThemeSwitch />
</Nav>
</nav>
)
}

const Nav = styled.nav`
width: 100%;
background-color: ${({ theme }) => theme.colors.neutrals[100]};
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 5px;
`

export { Navbar }
83 changes: 0 additions & 83 deletions {{cookiecutter.project_dirname}}/src/components/ThemeSwitch.tsx

This file was deleted.

24 changes: 0 additions & 24 deletions {{cookiecutter.project_dirname}}/src/components/commons/Button.tsx

This file was deleted.

62 changes: 0 additions & 62 deletions {{cookiecutter.project_dirname}}/src/components/commons/Input.tsx

This file was deleted.

Loading

0 comments on commit ac3a0a0

Please sign in to comment.