diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000000000000000000000000000000000..efdcb8ccdec7b83478ecca77880f821602f63b77 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "endOfLine": "auto", + "semi": false, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all", + "arrowParens": "avoid" +} diff --git a/babel.config.js b/babel.config.js index c5df3bc67841df467101eb2e9f19e800ab12122f..f1c965bcdc02c16b146866e329cbdadbe3d279db 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,7 @@ module.exports = { - presets: ['cozy-app'] + presets: ['@babel/typescript', 'cozy-app'], + plugins: [ + '@babel/transform-runtime', + '@babel/plugin-transform-modules-commonjs', + ], } diff --git a/package.json b/package.json index 1f990453c1627eee8f2d1af8bd4dcfeb9175dfbd..11ed792678b6b8bc859b9b05159c0b410d36090d 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,12 @@ "eslint-config-cozy-app": "^5.2.0", "git-directory-deploy": "1.5.1", "react-hot-loader": "4.13.0", - "react-test-renderer": "18.2.0" + "react-test-renderer": "18.2.0", + "typescript": "^5.5.4" }, "dependencies": { + "@babel/plugin-transform-modules-commonjs": "^7.24.8", + "@babel/plugin-transform-runtime": "^7.25.4", "cozy-client": "^34.5.0", "cozy-device-helper": "^2.6.0", "cozy-flags": "^2.10.2", diff --git a/src/components/Sidebar.jsx b/src/components/Sidebar.tsx similarity index 73% rename from src/components/Sidebar.jsx rename to src/components/Sidebar.tsx index 6bc04fee77d51b2a8e4a737f26aafcef15bab212..b0abafaa37775358c4c55500b5766135fe2035c0 100644 --- a/src/components/Sidebar.jsx +++ b/src/components/Sidebar.tsx @@ -8,7 +8,7 @@ import Nav, { NavItem, NavIcon, NavText, - NavLink + NavLink, } from 'cozy-ui/transpiled/react/Nav' import BulletPoint from 'src/assets/icons/icon-bullet-point.svg' @@ -24,7 +24,7 @@ const Sidebar = () => { to="/todos" className={({ isActive }) => cx(NavLink.className, { - [NavLink.activeClassName]: isActive + [NavLink.activeClassName]: isActive, }) } > @@ -37,7 +37,7 @@ const Sidebar = () => { to="/viewhello1" className={({ isActive }) => cx(NavLink.className, { - [NavLink.activeClassName]: isActive + [NavLink.activeClassName]: isActive, }) } > @@ -50,7 +50,7 @@ const Sidebar = () => { to="/viewhello2" className={({ isActive }) => cx(NavLink.className, { - [NavLink.activeClassName]: isActive + [NavLink.activeClassName]: isActive, }) } > @@ -58,6 +58,19 @@ const Sidebar = () => { <NavText>{t('nav.hello_nav_3')}</NavText> </RouterLink> </NavItem> + <NavItem> + <RouterLink + to="/dashboard" + className={({ isActive }) => + cx(NavLink.className, { + [NavLink.activeClassName]: isActive, + }) + } + > + <NavIcon icon={BulletPoint} /> + <NavText>{t('nav.dashboard')}</NavText> + </RouterLink> + </NavItem> </Nav> </UISidebar> ) diff --git a/src/locales/fr.json b/src/locales/fr.json index 1849ea73150427ae5adc848e7d63aac51d98c633..08085e7645d5f0f6b4fcf0cf234eb8ef2157b769 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -2,7 +2,8 @@ "nav": { "todos": "Tâches", "hello_nav_2": "Bonjour 1", - "hello_nav_3": "Bonjour 2" + "hello_nav_3": "Bonjour 2", + "dashboard": "Tableau de bord" }, "todoAdd": { "title": "Ajouter une nouvelle tâche:", diff --git a/src/types/cozy-ui.d.ts b/src/types/cozy-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..caee8db37cec96535ed888892c524e66b316058d --- /dev/null +++ b/src/types/cozy-ui.d.ts @@ -0,0 +1,38 @@ +declare module 'cozy-ui/transpiled/react/Icon' +declare module 'cozy-ui/transpiled/react/Spinner' +declare module 'cozy-ui/transpiled/react/Layout' +declare module 'cozy-ui/transpiled/react/helpers/appDataset' + +declare module 'cozy-ui/transpiled/react/I18n' { + interface IPropsIcon { + icon?: string + width?: string | number + height?: string | number + color?: string + className?: string + preserveColor?: string + rotate?: string + size?: string | number + spin?: any + [key: string]: any + } + interface IuseI18n { + t: (key: string, opt?: any) => string + f: (date: Date, format: string) => string + lang: string + } + + export function useI18n(): IuseI18n + export function Icon( + props: IPropsIcon, + ): React.CElement<any, React.Component<any, any, any>> + export const I18n: any + + export function initTranslation( + userLocal: string, + cb: (lang: string) => string, + ) +} + +declare module 'cozy-ui/transpiled/react/Sidebar' +declare module 'cozy-ui/transpiled/react/Nav' diff --git a/src/types/custom.d.ts b/src/types/custom.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c3a50175ffad9a357b86574d04428527d0ee49e --- /dev/null +++ b/src/types/custom.d.ts @@ -0,0 +1,8 @@ +declare module '*.png' { + const content: string + export default content +} +declare module '*.svg' { + const content: string + export default content +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..918223a92ae41951a898f2a5c62cdab1262f56d2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "esnext", + "baseUrl": ".", + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react", + "lib": ["esnext", "dom"], + "paths": { + "tests/*": ["tests/*"], + "*": ["src/*", "../node_modules/*", "types/*"] + } + }, + "include": ["src/**/*", "tests/**/*"] +} diff --git a/yarn.lock b/yarn.lock index ec24c56a3ef2f6d706e90e8055b4edcd27fd156a..720b5553605f2d2ee5e15e768d0a50f4b5085085 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1000,6 +1000,18 @@ babel-plugin-polyfill-regenerator "^0.6.1" semver "^6.3.1" +"@babel/plugin-transform-runtime@^7.25.4": + version "7.25.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.25.4.tgz#96e4ad7bfbbe0b4a7b7e6f2a533ca326cf204963" + integrity sha512-8hsyG+KUYGY0coX6KUCDancA0Vw225KJ2HJO0yCNr1vq5r+lJTleDaJf0K7iOhjw4SWhu03TMBzYTJ9krmzULQ== + dependencies: + "@babel/helper-module-imports" "^7.24.7" + "@babel/helper-plugin-utils" "^7.24.8" + babel-plugin-polyfill-corejs2 "^0.4.10" + babel-plugin-polyfill-corejs3 "^0.10.6" + babel-plugin-polyfill-regenerator "^0.6.1" + semver "^6.3.1" + "@babel/plugin-transform-shorthand-properties@^7.2.0", "@babel/plugin-transform-shorthand-properties@^7.24.7": version "7.24.7" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.24.7.tgz#85448c6b996e122fa9e289746140aaa99da64e73" @@ -3206,7 +3218,7 @@ babel-plugin-polyfill-corejs2@^0.4.10: "@babel/helper-define-polyfill-provider" "^0.6.2" semver "^6.3.1" -babel-plugin-polyfill-corejs3@^0.10.1, babel-plugin-polyfill-corejs3@^0.10.4: +babel-plugin-polyfill-corejs3@^0.10.1, babel-plugin-polyfill-corejs3@^0.10.4, babel-plugin-polyfill-corejs3@^0.10.6: version "0.10.6" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.10.6.tgz#2deda57caef50f59c525aeb4964d3b2f867710c7" integrity sha512-b37+KR2i/khY5sKmWNVQAnitvquQbNdWy6lJdsr0kmquCKEEUgMKK4SboVM3HtfnZilfjr4MMQ7vY58FVWDtIA== @@ -9422,9 +9434,9 @@ mini-css-extract-plugin@0.5.0: schema-utils "^1.0.0" webpack-sources "^1.1.0" -minilog@3.1.0, "minilog@git+https://github.com/cozy/minilog.git#master": +minilog@3.1.0, "minilog@https://github.com/cozy/minilog.git#master": version "3.1.0" - resolved "git+https://github.com/cozy/minilog.git#945cf4d569594d6e166d0187a83afd6c46cdf733" + resolved "https://github.com/cozy/minilog.git#945cf4d569594d6e166d0187a83afd6c46cdf733" dependencies: microee "0.0.6" @@ -9549,9 +9561,9 @@ ms@2.1.3, ms@^2.0.0, ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -"mui-bottom-sheet@git+https://github.com/cozy/mui-bottom-sheet.git#v1.0.9": +"mui-bottom-sheet@https://github.com/cozy/mui-bottom-sheet.git#v1.0.9": version "1.0.8" - resolved "git+https://github.com/cozy/mui-bottom-sheet.git#3dc4c2a245ab39079bc2f73546bccf80847be14c" + resolved "https://github.com/cozy/mui-bottom-sheet.git#3dc4c2a245ab39079bc2f73546bccf80847be14c" dependencies: "@juggle/resize-observer" "^3.1.3" jest-environment-jsdom-sixteen "^1.0.3" @@ -13248,6 +13260,11 @@ typescript@4.9.5, typescript@^4.3.5, typescript@^4.5.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +typescript@^5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== + uglify-js@3.4.x: version "3.4.10" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"