-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update from template repo: PRs 15, 24, 26 (#31)
* Copy over application-template-nextjs at ca2cc15. Install and configure storybook, sass, and USWDS 3.0 [#15](navapbc/template-application-nextjs#15) - Install and configure storybook - Create the first story - Install and configure [USWDS 3.0](https://designsystem.digital.gov/) as the design system - Modify `Dockerfile` and `docker-compose.yml` to support USWDS and storybook - Gitignore storybook, uswds assets, and compiled css - Prettier ignore uswds assets - Use postinstall hook to copy uswds static assets - Stop using CSS modules - Update some package dependencies - Switch Docker base image to use alpine for increased speed * Copy over application-template-nextjs at cd06ba6. Setup i18n for next.js, jest, and storybook [#24](navapbc/template-application-nextjs#24) - Install and configure [next-i18next](https://github.com/i18next/next-i18next) for Next.js internationalization - Move next.js i18n config out of `next.config.js` and into `next-i18next.config.js` - Modify `pages/_app.tsx` and `pages/index.tsx` to support i18n - Move jest i18n config into `/tests/jest-i18n.ts` - Install and configure [storybook-react-i18next](https://storybook.js.org/addons/storybook-react-i18next) for storybook internationalization - Add support for `<em>` tags in react-i18next in both next.js and storybook. Extras: - Remove `space-before-function-paren` eslint rule - Update eslint to follow prettier's rules - Rename `test` dir to `tests` (plural) * Copy over application-template-nextjs at cfe7c3d. Adds a src dir, layout component, alphabetizes imports [#26](navapbc/template-application-nextjs#26) - adds `src/` directory for project's webpack compilable JS and JSON files (this update is supported out of the box by [NextJS](https://nextjs.org/docs/advanced-features/src-directory) and pfml also uses this folder structure) - moves `api/`, `pages/` and `messages/` directories to `src/` - creates `components` directory and adds template `Layout` component Extras: - sets up prettier alphabetize imports - adds storybook-static to prettier ignore - sets $theme-show-compile-warnings to true for uswds * Copy over application-template-nextjs at 0a349fa. Enable dependabot version updates and codeql security scanning as CI jobs [#29](navapbc/template-application-nextjs#29) - Enable and configure [dependabot version updates](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates) - Enable and configure [codeql security scanning](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning) Note: These features were already enabled in this repo, so this commit is just bringing in stylistic updates to make the two repos identical. * Copy over application-template-nextjs at f59d2ac. Add layout styles missing from PR #26. [#37](navapbc/template-application-nextjs#37) * Also addresses: - #29 - #26 - #25 - #12 - #11
- Loading branch information
1 parent
9da4fae
commit b322ede
Showing
41 changed files
with
10,688 additions
and
1,323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# The docker container should install its own packages. | ||
node_modules | ||
|
||
# The docker container should ignore next builds. | ||
.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Ignoring generated files | ||
.next/ | ||
node_modules/ | ||
storybook-static/ | ||
|
||
# Ignore USWDS static assets | ||
public/uswds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"importOrder": ["^components/(.*)$", "^[./]"], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true, | ||
"semi": false, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Configure i18next for storybook addon storybook-react-i18next | ||
// See https://storybook.js.org/addons/storybook-react-i18next | ||
import i18n from 'i18next' | ||
import LanguageDetector from 'i18next-browser-languagedetector' | ||
import Backend from 'i18next-http-backend' | ||
import { initReactI18next } from 'react-i18next' | ||
|
||
const ns = ['common'] | ||
const supportedLngs = ['en', 'es'] | ||
const resources = ns.reduce((acc, n) => { | ||
supportedLngs.forEach((lng) => { | ||
if (!acc[lng]) acc[lng] = {} | ||
acc[lng] = { | ||
...acc[lng], | ||
[n]: require(`../public/locales/${lng}/${n}.json`), | ||
} | ||
}) | ||
return acc | ||
}, {}) | ||
|
||
i18n.use(initReactI18next).use(LanguageDetector).use(Backend).init({ | ||
lng: 'en', | ||
fallbackLng: 'en', | ||
defaultNS: 'common', | ||
ns, | ||
supportedLngs, | ||
resources, | ||
}) | ||
|
||
export default i18n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const nextConfig = require('../next.config') | ||
|
||
module.exports = { | ||
stories: ['../stories/**/*.stories.@(mdx|js|jsx|ts|tsx)'], | ||
addons: ['@storybook/addon-essentials', 'storybook-react-i18next'], | ||
framework: '@storybook/react', | ||
core: { | ||
// Use webpack5 instead of webpack4. | ||
builder: 'webpack5', | ||
disableTelemetry: true, | ||
}, | ||
// Tell storybook where to find USWDS static assets | ||
staticDirs: ['../public'], | ||
|
||
// Configure Storybook's final Webpack configuration in order to re-use the Next.js config/dependencies. | ||
webpackFinal: (config) => { | ||
config.module?.rules?.push({ | ||
test: /\.scss$/, | ||
use: [ | ||
'style-loader', | ||
'css-loader', | ||
{ | ||
/** | ||
* Next.js sets this automatically for us, but we need to manually set it here for Storybook. | ||
* The main thing this enables is autoprefixer, so any experimental CSS properties work. | ||
*/ | ||
loader: 'postcss-loader', | ||
options: { | ||
postcssOptions: { | ||
plugins: ['postcss-preset-env'], | ||
}, | ||
}, | ||
}, | ||
{ | ||
loader: 'sass-loader', | ||
options: { | ||
sassOptions: nextConfig.sassOptions, | ||
}, | ||
}, | ||
], | ||
exclude: /node_modules/, | ||
}) | ||
|
||
// Required for i18next. | ||
config.resolve.fallback = { | ||
fs: false, | ||
path: false, | ||
os: false, | ||
} | ||
|
||
return config | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Apply global styling to our stories | ||
import '../styles/styles.scss' | ||
// Import i18next config. | ||
import i18n from './i18next.js' | ||
|
||
export const parameters = { | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
// Configure i18next and locale/dropdown options. | ||
i18n, | ||
locale: 'en', | ||
locales: { | ||
en: 'English', | ||
es: 'Español', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
# Use the Active LTS version of Node. | ||
# See https://nodejs.org/en/about/releases/ | ||
FROM node:16 | ||
FROM node:16-alpine | ||
# Keep container packages up-to-date. | ||
RUN apt update \ | ||
&& apt upgrade -y | ||
# Copy all the application files to a working directory. | ||
COPY . /srv | ||
# -U runs both apk update and apk upgrade. | ||
RUN apk -U upgrade | ||
# Copy just the package data to the working directory. | ||
COPY yarn.lock /srv | ||
COPY package.json /srv | ||
WORKDIR /srv | ||
# Install application dependencies and build the applicatian. | ||
# See package.json for yarn commands. | ||
RUN yarn install --frozen-lockfile \ | ||
&& yarn build | ||
# Install application dependencies. | ||
RUN yarn install --frozen-lockfile | ||
# Copy all the remaining application files (ignoring files in .dockerignore) to the working directory. | ||
COPY . /srv | ||
# Build the application. | ||
RUN yarn build | ||
# Run the application. | ||
CMD yarn start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
i18n: { | ||
defaultLocale: 'en', | ||
locales: ['en', 'es'], | ||
react: { | ||
// Add support for <em>. | ||
// See https://react.i18next.com/latest/trans-component#using-for-less-than-br-greater-than-and-other-simple-html-elements-in-translations-v-10-4-0 | ||
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p', 'em'], | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
/** @type {import('next').NextConfig} */ | ||
|
||
const { i18n } = require('./next-i18next.config') | ||
|
||
const nextConfig = { | ||
i18n: { | ||
// TODO: implement i18n internationalization-- look into nextJS subpath routing | ||
locales: ['en-US', 'es-ES'], | ||
defaultLocale: 'en-US', | ||
localeSubpaths: { | ||
es: 'es', | ||
}, | ||
}, | ||
i18n, | ||
reactStrictMode: true, | ||
sassOptions: { | ||
includePaths: [ | ||
'./node_modules/@uswds', | ||
'./node_modules/@uswds/uswds/packages', | ||
], | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
Oops, something went wrong.