nitro-web 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.eslintrc.json +2 -5
  2. package/_example/{.env-example → .env} +3 -3
  3. package/_example/client/config.ts +1 -5
  4. package/_example/client/index.ts +1 -18
  5. package/_example/components/auth.api.js +1 -1
  6. package/_example/components/index.tsx +11 -3
  7. package/_example/components/settings.api.js +1 -1
  8. package/_example/package.json +109 -0
  9. package/_example/server/config.js +3 -16
  10. package/_example/server/index.js +4 -3
  11. package/_example/tailwind.config.js +12 -21
  12. package/_example/tsconfig.json +2 -2
  13. package/_example/types/index.d.ts +13 -0
  14. package/_example/types/twin.d.ts +19 -0
  15. package/_example/webpack.config.js +2 -3
  16. package/client/index.js +42 -0
  17. package/components/auth/signin.jsx +9 -1
  18. package/components/partials/element/modal.jsx +1 -1
  19. package/components/partials/form/drop-handler.jsx +1 -1
  20. package/components/partials/form/input-currency.jsx +5 -2
  21. package/components/partials/form/input-date.jsx +6 -6
  22. package/components/partials/form/input.jsx +9 -9
  23. package/components/partials/layout/layout2.jsx +1 -1
  24. package/components/partials/styleguide.jsx +6 -7
  25. package/components/settings/settings-account.jsx +1 -1
  26. package/components/settings/settings-business.jsx +1 -4
  27. package/components/settings/settings-team--member.jsx +1 -1
  28. package/package.json +28 -97
  29. package/readme.md +39 -9
  30. package/server/email/index.js +12 -10
  31. package/server/index.js +23 -0
  32. package/server/router.js +4 -8
  33. package/util.js +13 -0
  34. package/webpack.config.js +43 -42
  35. package/_example/types.d.ts +0 -7
  36. package/client.js +0 -42
  37. package/server.js +0 -20
package/.eslintrc.json CHANGED
@@ -8,8 +8,7 @@
8
8
  "env": {
9
9
  "browser": true,
10
10
  "es6": true,
11
- "node": true,
12
- "jest/globals": true
11
+ "node": true
13
12
  },
14
13
  "globals": {
15
14
  // Project globals
@@ -19,7 +18,6 @@
19
18
  "sharedStore": true,
20
19
  "sharedStoreCache": true,
21
20
  // Dependency globals
22
- "Component": true,
23
21
  "Link": true,
24
22
  "forwardRef": true,
25
23
  "useCallback": true,
@@ -39,7 +37,6 @@
39
37
  "sourceType": "module"
40
38
  },
41
39
  "plugins": [
42
- "jest",
43
40
  "react",
44
41
  "react-hooks",
45
42
  "import",
@@ -80,7 +77,7 @@
80
77
  },
81
78
  "settings": {
82
79
  "react": {
83
- "version": "16.3"
80
+ "version": "18"
84
81
  }
85
82
  }
86
83
  }
@@ -3,8 +3,8 @@ awsBucket=nitro-dev
3
3
  awsRegion=ap-southeast-2
4
4
  awsSecretAccessKey=
5
5
  awsUrl=https://s3-ap-southeast-2.amazonaws.com/
6
- emailFrom=Nitro<nitro@nitro.com>
7
- emailReplyTo=Nitro<nitro@nitro.com>
6
+ emailFrom=Nitro<bruce@wayneenterprises.com>
7
+ emailReplyTo=Nitro<bruce@wayneenterprises.com>
8
8
  emailTestMode=true
9
9
  googleMapsApiKey=
10
10
  mailgunDomain=mg.nitro.com
@@ -13,4 +13,4 @@ masterPassword=1234
13
13
  mongoUrl=localhost:27017/nitro-dev
14
14
  stripePublishableKey=
15
15
  stripeSecretKey=
16
- testEmail=
16
+ testEmail=bruce@wayneenterprises.com
@@ -1,5 +1 @@
1
- declare const CONFIG: Record<string, any>
2
- const config = {}
3
- Object.assign(config, CONFIG) // Injected environment variables from webpack
4
-
5
- export default config
1
+ export default { ...CONFIG } // Environment variables from webpack
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Component, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
2
+ import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
3
3
  import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
4
4
  import { setupApp, onChange } from 'nitro-web'
5
5
 
@@ -14,7 +14,6 @@ Object.assign(window, {
14
14
  sharedStoreCache: undefined, // defined in setupApp
15
15
 
16
16
  // dependency globals
17
- Component: Component,
18
17
  Link: Link,
19
18
  useCallback: useCallback,
20
19
  useEffect: useEffect,
@@ -29,19 +28,3 @@ Object.assign(window, {
29
28
 
30
29
  // Fetch state and start app
31
30
  setupApp(config, [Layout1, Layout2])
32
-
33
- // Hot reload fallback if fast reload didn't work
34
- // if ((import.meta as any).webpackHot) {
35
- // (import.meta as any).webpackHot.accept()
36
- // (import.meta as any).webpackHot.dispose((data: any) => {
37
- // (window as any).prehot = { sharedStoreCache: (window as any).sharedStoreCache }
38
- // })
39
- // }
40
-
41
- // Hot reload fallback if fast reload didn't work
42
- // if ((module as any).hot) {
43
- // (module as any).hot.accept()
44
- // ;(module as any).hot.dispose(() => {
45
- // (window as any).prehot = { sharedStoreCache: (window as any).sharedStoreCache }
46
- // })
47
- // }
@@ -1 +1 @@
1
- export { auth as default } from '#nitro-web/server.js'
1
+ export { auth as default } from 'nitro-web/server'
@@ -15,7 +15,7 @@ import {
15
15
  } from 'nitro-web'
16
16
  import config from '../client/config'
17
17
 
18
- // Signin page (can be saved onto a seperate file under the components folder)
18
+ // Signin page (can be saved onto a seperate .jsx/.tsx file under the components folder)
19
19
  export const SigninPage = () => <Signin config={config} />
20
20
  SigninPage.route = {
21
21
  '/signin': true,
@@ -66,9 +66,11 @@ ResetPasswordPage.route = {
66
66
  // }
67
67
 
68
68
  // Dashboard page
69
+ import { css, theme } from 'twin.macro'
70
+
69
71
  export function DashboardPage() {
70
72
  return (
71
- <div>
73
+ <div css={style}>
72
74
  <h1 className="h1 mb-8">Dashboard</h1>
73
75
  <p className="text-gray-700">
74
76
  Welcome to Nitro, a modular React/Express base project, styled using Tailwind 🚀.
@@ -76,6 +78,11 @@ export function DashboardPage() {
76
78
  </div>
77
79
  )
78
80
  }
81
+ const style = css`
82
+ p,.example-usage-of-tailwind-variable {
83
+ color: ${theme('colors.dark')};
84
+ }
85
+ `
79
86
  DashboardPage.route = {
80
87
  '/': true,
81
88
  'meta': { 'title': 'Dashboard - Nitro', layout: 1 },
@@ -222,4 +229,5 @@ export function PricingPage() {
222
229
  PricingPage.route = {
223
230
  '/pricing': true,
224
231
  'meta': { 'title': 'Pricing - Nitro', layout: 1 },
225
- }
232
+ }
233
+
@@ -1 +1 @@
1
- export { settings as default } from '#nitro-web/server.js'
1
+ export { settings as default } from 'nitro-web/server'
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "example",
3
+ "private": true,
4
+ "version": "0.0.1",
5
+ "main": "webpack.config.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "NODE_ENV=production webpack --target=web",
9
+ "dev": "clear && npm run dev:lint --silent & npm run dev:server --silent & npm run dev:client --silent",
10
+ "dev:client": "webpack serve --progress --config ./webpack.config.js",
11
+ "dev:server": "nodemon ./server -q -w ./server/ -w ./components/ -e js",
12
+ "dev:lint": "eslint ./components ./server/",
13
+ "minor": "standard-version --release-as minor && git push staging",
14
+ "patch": "standard-version --release-as patch && git push staging",
15
+ "start": "node ./server",
16
+ "stripe": "stripe listen --forward-to localhost:3001/api/stripe/webhook"
17
+ },
18
+ "dependencies": {
19
+ "@headlessui/react": "^2.2.0",
20
+ "@heroicons/react": "^2.2.0",
21
+ "@hokify/axios": "^0.19.1",
22
+ "@stripe/stripe-js": "^1.34.0",
23
+ "axios-retry": "^3.3.1",
24
+ "monastery": "~3.5.2",
25
+ "nitro-web": "file:..",
26
+ "react": "^18.3.1",
27
+ "react-dom": "^18.3.1",
28
+ "stripe": "^9.16.0",
29
+ "twin.macro": "^3.4.1"
30
+ },
31
+ "devDependencies": {
32
+ "@babel/core": "^7.8.0",
33
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
34
+ "@babel/plugin-transform-runtime": "^7.17.0",
35
+ "@babel/preset-env": "^7.8.0",
36
+ "@babel/preset-react": "^7.9.4",
37
+ "@babel/preset-typescript": "^7.24.7",
38
+ "@emotion/babel-plugin": "^11.11.0",
39
+ "@emotion/eslint-plugin": "^11.11.0",
40
+ "@emotion/react": "^11.11.4",
41
+ "@emotion/styled": "^11.11.4",
42
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
43
+ "@svgr/webpack": "^8.1.0",
44
+ "@types/react": "^19.0.2",
45
+ "@types/react-dom": "^19.0.2",
46
+ "@typescript-eslint/eslint-plugin": "^8.18.1",
47
+ "@typescript-eslint/parser": "^8.18.1",
48
+ "autoprefixer": "^9.8.8",
49
+ "babel-loader": "^8.0.6",
50
+ "babel-plugin-macros": "^3.1.0",
51
+ "babel-plugin-react-html-attrs": "^2.1.0",
52
+ "clean-terminal-webpack-plugin": "https://github.com/boycce/clean-terminal-webpack-plugin.git",
53
+ "color": "^4.2.3",
54
+ "copy-webpack-plugin": "^12.0.2",
55
+ "core-js": "^3.12.1",
56
+ "css-loader": "^3.6.0",
57
+ "csv-loader": "^3.0.5",
58
+ "eslint": "^8.57.1",
59
+ "eslint-plugin-import": "^2.26.0",
60
+ "eslint-plugin-react": "^7.19.0",
61
+ "eslint-plugin-react-hooks": "^4.0.0",
62
+ "eslint-webpack-plugin": "^2.7.0",
63
+ "html-loader": "^1.3.2",
64
+ "html-webpack-plugin": "^5.6.0",
65
+ "mini-css-extract-plugin": "^2.9.0",
66
+ "nodemon": "^2.0.1",
67
+ "postcss": "^8.4.49",
68
+ "postcss-for": "^2.1.1",
69
+ "postcss-import": "^16.1.0",
70
+ "postcss-loader": "^8.1.1",
71
+ "postcss-nested": "^7.0.2",
72
+ "react-refresh": "^0.14.2",
73
+ "standard-version": "^9.3.2",
74
+ "string-replace-loader": "^3.1.0",
75
+ "tailwind-merge": "^2.6.0",
76
+ "tailwindcss": "^3.4.17",
77
+ "typescript": "^5.5.2",
78
+ "webpack": "^5.92.1",
79
+ "webpack-cli": "^5.1.4",
80
+ "webpack-dev-server": "^4.6.0",
81
+ "webpack-node-externals": "^1.7.2"
82
+ },
83
+ "eslintConfig": {
84
+ "extends": "../.eslintrc.json"
85
+ },
86
+ "engines": {
87
+ "node": "^18"
88
+ },
89
+ "browserslist": [
90
+ "> 1%",
91
+ "last 2 versions",
92
+ "not ie <= 10"
93
+ ],
94
+ "nodemonConfig": {
95
+ "events": {
96
+ "restart": "echo \"\\033[0;35mExpress restarting..\\033[0m\""
97
+ }
98
+ },
99
+ "standard-version": {
100
+ "releaseCommitMessageFormat": "{{currentTag}}",
101
+ "sign": true,
102
+ "skip": {
103
+ "changelog": true,
104
+ "tag": true
105
+ }
106
+ },
107
+ "author": "",
108
+ "license": "ISC"
109
+ }
@@ -1,16 +1,12 @@
1
1
  import 'dotenv/config'
2
- import { dirname, resolve } from 'path'
3
- import { fileURLToPath } from 'url'
4
2
  import { createRequire } from 'module'
5
3
  const _require = createRequire(import.meta.url)
6
- const projectDir = resolve(dirname(fileURLToPath(import.meta.url)) + '/../') + '/'
7
4
  const env = process.env.env || (process.env.NODE_ENV !== 'production' ? 'development' : process.env.NODE_ENV)
8
- const isNitro = process.env.NITRO
5
+ const pwd = process.env.PWD + '/'
9
6
 
10
7
  export default {
11
8
  inject: 'awsUrl clientUrl currencies countries env googleMapsApiKey stripePublishableKey testEmail',
12
9
 
13
- // apiUrl: process.env.originUrl || 'http://localhost:3001',
14
10
  clientUrl: process.env.originUrl || 'http://localhost:3000',
15
11
  emailFrom: process.env.emailFrom,
16
12
  emailReplyTo: process.env.emailReplyTo,
@@ -20,15 +16,6 @@ export default {
20
16
  mongoUrl: process.env.mongoUrl,
21
17
  testEmail: process.env.testEmail,
22
18
 
23
- clientDir: projectDir + 'client/',
24
- componentsDir: projectDir + 'components/',
25
- distDir: projectDir + 'client/dist/',
26
- emailTemplateDir: projectDir + 'server/email/',
27
- modelsDir: projectDir + 'server/models/',
28
- projectDir: projectDir,
29
- tmpDir: projectDir + 'tmp/',
30
- nitroDir: resolve(isNitro ? projectDir + '../' : projectDir + 'node_modules/nitro-web/') + '/',
31
-
32
19
  awsUrl: process.env.awsUrl,
33
20
  googleMapsApiKey: process.env.googleMapsApiKey,
34
21
  mailgunDomain: process.env.mailgunDomain,
@@ -115,6 +102,6 @@ export default {
115
102
  },
116
103
  },
117
104
 
118
- version: _require(projectDir + (isNitro ? '../' : '') + 'package.json').version,
119
- isNitro: isNitro,
105
+ pwd: pwd,
106
+ version: _require(pwd + 'package.json').version,
120
107
  }
@@ -1,11 +1,11 @@
1
1
  import 'dotenv/config'
2
2
  import db from 'monastery'
3
3
  import config from './config.js'
4
- import { setupRouter, setupDefaultModels } from '#nitro-web/server.js'
4
+ import { setupRouter, setupDefaultModels } from 'nitro-web/server'
5
5
 
6
6
  // Setup monastery models
7
7
  db.manager(config.mongoUrl, config.monasteryOptions)
8
- await db.models(config.modelsDir)
8
+ await db.models(config.pwd + 'server/models')
9
9
  await setupDefaultModels(db)
10
10
 
11
11
  // Catch mongod not running
@@ -21,7 +21,8 @@ server.listen(process.env.PORT || 3001, '0.0.0.0', async () => {
21
21
  // ...success
22
22
  })
23
23
 
24
- // You can send emails like this:
24
+ // You can send transactional Mailgun emails like so:
25
+ // import { sendEmail } from '#nitro-web/server.js'
25
26
  // const html = await sendEmail({
26
27
  // config: config,
27
28
  // data: { name: 'Test' },
@@ -1,17 +1,17 @@
1
- /** @type {import('tailwindcss').Config} */
2
1
  // https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L889
3
2
  import defaultTheme from 'tailwindcss/defaultTheme'
4
3
  import colors from 'tailwindcss/colors'
5
- import { nitroDir } from './server/config'
4
+ import path from 'path'
6
5
  import Color from 'color'
7
6
  const lighten = (clr, val) => Color(clr).lighten(val).rgb().string()
7
+ const nitroDir = path.dirname(require.resolve('nitro-web'))
8
8
 
9
9
  export default {
10
10
  content: {
11
11
  relative: true,
12
12
  files: [
13
13
  './components/**/*.{ts,tsx}',
14
- nitroDir + 'components/**/*.{js,jsx}',
14
+ path.join(nitroDir, '../components/**/*.{js,jsx}'),
15
15
  ],
16
16
  },
17
17
  experimental: {
@@ -54,24 +54,15 @@ export default {
54
54
  sans: ['Inter', ...defaultTheme.fontFamily.sans],
55
55
  },
56
56
  fontSize: {
57
- // '2xs': ['0.75rem', { lineHeight: '1.5' }],
58
- // 'xs': ['0.81rem', { lineHeight: '1.5' }],
59
- // 'sm': ['0.875rem', { lineHeight: '1.5' }],
60
- // 'base': ['1rem', { lineHeight: '1.5' }],
61
- // 'lg': ['1.125rem', { lineHeight: '1.75' }],
62
- // 'xl': ['1.25rem', { lineHeight: '1.75' }],
63
- // '2xl': ['1.4rem', { lineHeight: '1.75' }],
64
- // '3xl': ['1.875rem', { lineHeight: '1.75' }],
65
-
66
- '2xs': ['0.77rem', { lineHeight: '1.5' }], // ~12px
67
- 'xs': ['0.83rem', { lineHeight: '1.5' }], // ~13px
68
- 'sm-label': ['0.87rem', { lineHeight: '1.5' }], // ~13.5px
69
- 'sm': ['0.90rem', { lineHeight: '1.5' }], // ~14px
70
- 'base': ['1rem', { lineHeight: '1.5' }], // 15.5px
71
- 'lg': ['1.16rem', { lineHeight: '1.75' }], // ~18px
72
- 'xl': ['1.29rem', { lineHeight: '1.75' }], // ~20px
73
- '2xl': ['1.45rem', { lineHeight: '1.75' }], // ~22.4px
74
- '3xl': ['1.94rem', { lineHeight: '1.75' }], // ~30px
57
+ '2xs': ['0.77rem', { lineHeight: '1.5' }],
58
+ 'xs': ['0.83rem', { lineHeight: '1.5' }],
59
+ 'sm-label': ['0.87rem', { lineHeight: '1.5' }],
60
+ 'sm': ['0.90rem', { lineHeight: '1.5' }],
61
+ 'base': ['1rem', { lineHeight: '1.5' }],
62
+ 'lg': ['1.16rem', { lineHeight: '1.75' }],
63
+ 'xl': ['1.29rem', { lineHeight: '1.75' }],
64
+ '2xl': ['1.45rem', { lineHeight: '1.75' }],
65
+ '3xl': ['1.94rem', { lineHeight: '1.75' }],
75
66
  },
76
67
  spacing: {
77
68
  'input-before': '0.625rem',
@@ -19,7 +19,7 @@
19
19
  "outDir": "./dist",
20
20
  "paths": {
21
21
  "nitro-web": [
22
- "../client.js"
22
+ "../client/index.js",
23
23
  ],
24
24
  },
25
25
  "resolveJsonModule": true,
@@ -28,5 +28,5 @@
28
28
  "strict": true,
29
29
  "target": "es6",
30
30
  },
31
- "include": ["client", "components", "types.d.ts"],
31
+ "include": ["client", "components", "types"],
32
32
  }
@@ -0,0 +1,13 @@
1
+ // Shared store
2
+ declare global {
3
+ const sharedStore: Record<string, unknown>
4
+ }
5
+
6
+ // Svgs
7
+ declare module '*.svg' {
8
+ const content: string | React.FC<React.SVGProps<SVGElement>>
9
+ export default content
10
+ }
11
+
12
+ // Webpack config
13
+ declare const CONFIG: Record<string, string>
@@ -0,0 +1,19 @@
1
+ // Twin.macro - https://github.com/ben-rogerson/twin.examples/tree/master/react-emotion-typescript
2
+ import 'twin.macro'
3
+ import { css as cssImport } from '@emotion/react'
4
+ import styledImport from '@emotion/styled'
5
+ import { CSSInterpolation } from '@emotion/serialize'
6
+
7
+ declare module 'twin.macro' {
8
+ // The styled and css imports
9
+ const styled: typeof styledImport
10
+ const css: typeof cssImport
11
+ }
12
+
13
+ declare module 'react' {
14
+ // The tw and css prop
15
+ interface DOMAttributes<T> {
16
+ tw?: string
17
+ css?: CSSInterpolation
18
+ }
19
+ }
@@ -1,4 +1,3 @@
1
1
  import config from './server/config.js'
2
- import { getWebpackConfig } from '#nitro-web/webpack.config.js'
3
-
4
- export default getWebpackConfig(config)
2
+ import { getConfig } from 'nitro-web/webpack.config.js'
3
+ export default getConfig(config)
@@ -0,0 +1,42 @@
1
+ export * from './app.js'
2
+ export * from '../util.js'
3
+ export * as util from '../util.js'
4
+
5
+ // Components: Pages
6
+ export { Signin } from '../components/auth/signin.jsx'
7
+ export { Signup } from '../components/auth/signup.jsx'
8
+ export { ResetInstructions, ResetPassword } from '../components/auth/reset.jsx'
9
+ // export { SettingsAccount } from '../components/settings/settings-account.jsx'
10
+ // export { SettingsBusiness } from '../components/settings/settings-business.jsx'
11
+ // export { SettingsTeamMember } from '../components/settings/settings-team--member.jsx'
12
+ // export { SettingsTeam } from '../components/settings/settings-team.jsx'
13
+
14
+ // Components: partials: elements
15
+ export { Accordion } from '../components/partials/element/accordion.jsx'
16
+ export { Avatar } from '../components/partials/element/avatar.jsx'
17
+ export { Button } from '../components/partials/element/button.jsx'
18
+ export { Dropdown } from '../components/partials/element/dropdown.jsx'
19
+ export { Initials } from '../components/partials/element/initials.jsx'
20
+ export { Message } from '../components/partials/element/message.jsx'
21
+ // export { Modal } from '../components/partials/element/modal.jsx'
22
+ export { Sidebar } from '../components/partials/element/sidebar.jsx'
23
+ export { Tooltip } from '../components/partials/element/tooltip.jsx'
24
+ export { Topbar } from '../components/partials/element/topbar.jsx'
25
+
26
+ // Components: partials: form
27
+ export { Checkbox } from '../components/partials/form/checkbox.jsx'
28
+ export { Drop } from '../components/partials/form/drop.jsx'
29
+ export { FormError } from '../components/partials/form/form-error.jsx'
30
+ export { Input } from '../components/partials/form/input.jsx'
31
+ export { Location } from '../components/partials/form/location.jsx'
32
+ export { Select } from '../components/partials/form/select.jsx'
33
+ export { Toggle } from '../components/partials/form/toggle.jsx'
34
+
35
+ // Components: partials: layouts
36
+ export { Layout1 } from '../components/partials/layout/layout1.jsx'
37
+ export { Layout2 } from '../components/partials/layout/layout2.jsx'
38
+
39
+ // Components: partials: other
40
+ export { IsFirstRender } from '../components/partials/is-first-render.js'
41
+ export { NotFound } from '../components/partials/not-found.jsx'
42
+ export { Styleguide } from '../components/partials/styleguide.jsx'
@@ -1,3 +1,4 @@
1
+ import { css, theme } from 'twin.macro'
1
2
  import * as util from '../../util.js'
2
3
  import { Topbar } from '../partials/element/topbar.jsx'
3
4
  import { Input } from '../partials/form/input.jsx'
@@ -46,7 +47,8 @@ export function Signin({ config }) {
46
47
  }
47
48
 
48
49
  return (
49
- <div>
50
+ <div css={style}>
51
+ {/* <div> */}
50
52
  <Topbar title={<>Sign in to your Account</>} />
51
53
 
52
54
  <form onSubmit={onSubmit}>
@@ -72,3 +74,9 @@ export function Signin({ config }) {
72
74
  </div>
73
75
  )
74
76
  }
77
+
78
+ const style = css`
79
+ .example-usage-of-tailwind-variable {
80
+ color: ${theme('colors.primary')};
81
+ }
82
+ `
@@ -221,7 +221,7 @@ const style = () => css`
221
221
  }
222
222
  &:hover {
223
223
  line {
224
- stroke: ${theme('colors.primary-dark')};
224
+ /* stroke: theme'colors.primary-dark'; */
225
225
  }
226
226
  }
227
227
  }
@@ -54,7 +54,7 @@ export const DropHandler = ({ onDrop, children, className }) => {
54
54
  return (
55
55
  <div
56
56
  ref={dropRef}
57
- class={`${className} relative w-full p-[20px] border border-dashed border-input-border border-2 rounded-md ${dragging ? 'border-primary before:content-[""] before:absolute before:inset-0 before:bg-primary before:opacity-5' : ''}`}
57
+ class={`${className} relative w-full p-[20px] border-2 border-dashed border-input-border rounded-md ${dragging ? 'border-primary before:content-[""] before:absolute before:inset-0 before:bg-primary before:opacity-5' : ''}`}
58
58
  >
59
59
  {children}
60
60
  </div>
@@ -11,6 +11,11 @@ import { getCurrencyPrefixWidth } from '../../../util.js'
11
11
  * @param {cents} [value] - e.g. 123 (input is always controlled if state is passed in)
12
12
  */
13
13
  export function InputCurrency({ id, config, className, currency='nzd', onChange, placeholder, value }) {
14
+ if (!config?.currencies || !config?.countries) {
15
+ throw new Error(
16
+ 'InputCurrency: `config.currencies` and `config.countries` is required, check out the nitro example for more info.'
17
+ )
18
+ }
14
19
  const ref = useRef()
15
20
  const [dontFix, setDontFix] = useState()
16
21
  const [settings, setSettings] = useState(() => getCurrencySettings(currency))
@@ -18,8 +23,6 @@ export function InputCurrency({ id, config, className, currency='nzd', onChange,
18
23
  const [prefixWidth, setPrefixWidth] = useState()
19
24
  ref.current = { settings, dontFix }
20
25
 
21
- if (!config) throw new Error('InputCurrency: `config` is required')
22
-
23
26
  useEffect(() => {
24
27
  if (settings.currency !== currency) {
25
28
  const settings = getCurrencySettings(currency)
@@ -1,5 +1,5 @@
1
1
  // todo: finish tailwind conversion
2
- import { css, theme } from 'twin.macro'
2
+ import { css } from 'twin.macro'
3
3
  import { DayPicker } from 'react-day-picker'
4
4
  import { format, isValid, parse } from 'date-fns'
5
5
  import { getCurrencyPrefixWidth } from '../../../util.js'
@@ -124,7 +124,7 @@ const style = () => css`
124
124
  .rdp {
125
125
  --rdp-cell-size: 34px;
126
126
  --rdp-caption-font-size: 12px;
127
- --rdp-accent-color: ${theme('colors.primary')};
127
+ --rdp-accent-color: blue; /* theme('colors.primary') */
128
128
  font-size: 13px;
129
129
  margin: 0 12px 11px;
130
130
  svg {
@@ -179,7 +179,7 @@ const style = () => css`
179
179
  &:active {
180
180
  color: white;
181
181
  &:before {
182
- background-color: ${theme('colors.primary')};
182
+ background-color: blue; /* theme('colors.primary') */
183
183
  }
184
184
  }
185
185
  }
@@ -188,15 +188,15 @@ const style = () => css`
188
188
  color: white;
189
189
  :before {
190
190
  border-radius: 50%;
191
- background-color: ${theme('colors.primary')};
191
+ background-color: blue; /* theme('colors.primary') */
192
192
  }
193
193
  }
194
194
  .rdp-day_range_middle {
195
- color: ${theme('colors.dark')};
195
+ color: black; /* theme('colors.dark') */
196
196
  :before {
197
197
  border-radius: 0;
198
198
  border: 1px solid rgb(151 133 185);
199
- background-color: ${theme('colors.primary-light')};
199
+ background-color: blue; /* theme('colors.primary-light') */
200
200
  }
201
201
  }
202
202
  .rdp-day_range_start,
@@ -1,5 +1,4 @@
1
- /* eslint-disable brace-style */
2
- import { css } from '@emotion/react'
1
+ import { css } from 'twin.macro'
3
2
  import * as util from '../../../util.js'
4
3
  import { InputCurrency } from './input-currency.jsx'
5
4
  import { InputColor } from './input-color.jsx'
@@ -67,6 +66,9 @@ export function Input({ name='', state, id, type='text', ...props }) {
67
66
  InputEl = InputCurrency
68
67
  }
69
68
 
69
+ // Icon
70
+ const iconEl = <IconEl iconDir={iconDir} IconSvg={IconSvg} onClick={onClick} type={type} />
71
+
70
72
  // Create base props object
71
73
  const inputProps = {
72
74
  ...props,
@@ -74,6 +76,7 @@ export function Input({ name='', state, id, type='text', ...props }) {
74
76
  id: id || name,
75
77
  type: inputType,
76
78
  value: value,
79
+ iconEl: iconEl,
77
80
  className:
78
81
  'col-start-1 row-start-1 block w-full rounded-md bg-white py-2 text-sm outline outline-1 -outline-offset-1 ' +
79
82
  'placeholder:text-input-placeholder focus:outline focus:outline-2 focus:-outline-offset-2 sm:text-sm/6 ' +
@@ -83,16 +86,12 @@ export function Input({ name='', state, id, type='text', ...props }) {
83
86
  }
84
87
 
85
88
  // Only add iconEl prop for custom components
86
- const showIconElHere = !['color', 'date'].includes(type)
87
- const iconEl = <IconEl iconDir={iconDir} IconSvg={IconSvg} onClick={onClick} type={type} />
88
- if (!showIconElHere) {
89
- inputProps.iconEl = iconEl
90
- }
89
+ if (!['color', 'date'].includes(type)) delete inputProps.iconEl
91
90
 
92
91
  return (
93
92
  // https://tailwindui.com/components/application-ui/forms/input-groups#component-474bd025b849b44eb3c46df09a496b7a
94
93
  <div css={style} className={`mt-input-before mb-input-after grid grid-cols-1 ${props?.className || ''}`}>
95
- { showIconElHere && iconEl }
94
+ { !inputProps.iconEl && iconEl }
96
95
  <InputEl {...inputProps} />
97
96
  {error && <div class="mt-1.5 text-xs text-danger">{error.detail}</div>}
98
97
  </div>
@@ -104,7 +103,7 @@ function IconEl({ iconDir, IconSvg, onClick, type }) {
104
103
  return (
105
104
  !!IconSvg &&
106
105
  <div
107
- className={`col-start-1 row-start-1 ${iconSize} self-center text-gray-400 select-none relative z-[1] ` +
106
+ className={`col-start-1 row-start-1 ${iconSize} self-center text-[#c6c8ce] select-none relative z-[1] ` +
108
107
  `pointer-events-${type == 'password' ? 'auto' : 'none'} ` +
109
108
  (iconDir == 'right' ? 'justify-self-end mr-3' : 'justify-self-start ml-3')
110
109
  }
@@ -121,6 +120,7 @@ function ColorIcon({ hex }) {
121
120
 
122
121
  const style = () => css`
123
122
  input {
123
+ appearance: textfield;
124
124
  -moz-appearance: textfield;
125
125
  }
126
126
  input::-webkit-outer-spin-button,