Skip to content

Commit

Permalink
fix: FRM-1819 add custom detection element addon flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KenLSM committed Sep 18, 2024
1 parent f8514e4 commit 2998079
Show file tree
Hide file tree
Showing 7 changed files with 1,117 additions and 472 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
- name: Publish to Chromatic
uses: chromaui/action@v1
# Chromatic GitHub Action options
env:
NODE_OPTIONS: --max-old-space-size=8192
with:
token: ${{ secrets.GITHUB_TOKEN }}
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
Expand All @@ -68,3 +70,7 @@ jobs:
skip: dependabot/**
# Only run when the frontend directory has changes
untraced: '!(frontend)/**'
# temp debug options
# debug: true
# diagnosticsFile: true
# logFile: true
1,546 changes: 1,078 additions & 468 deletions frontend/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"@types/validator": "^13.7.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react": "^4.3.1",
"chromatic": "^6.2.0",
"cross-env": "^7.0.3",
"env-cmd": "^10.1.0",
Expand All @@ -179,7 +179,7 @@
"rimraf": "^3.0.2",
"storybook": "8.0.9",
"storybook-react-i18next": "^3.0.1",
"vite": "^5.2.10",
"vite": "^5.4.6",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.5.2",
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export interface InputProps extends ChakraInputProps {
* Whether to prevent default on user pressing the 'Enter' key.
*/
preventDefaultOnEnter?: boolean
/**
* Whether there's an input right element. Used to provide additional padding
*/
hasInputRightElement?: boolean
}

export const Input = forwardRef<InputProps, 'input'>((props, ref) => {
Expand All @@ -45,6 +49,7 @@ export const Input = forwardRef<InputProps, 'input'>((props, ref) => {
'isPrefilled',
'isPrefillLocked',
'preventDefaultOnEnter',
'hasInputRightElement',
])

const preventDefault = useMemo(
Expand Down Expand Up @@ -102,7 +107,11 @@ export const Input = forwardRef<InputProps, 'input'>((props, ref) => {
ref={ref}
{...preventDefault}
{...inputProps}
sx={props.sx ?? inputStyles.field}
sx={merge(
props.hasInputRightElement ? { pr: '2.75rem' } : {},
inputStyles.field,
props.sx,
)}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export const EditShortText = ({ field }: EditShortTextProps): JSX.Element => {
field._id ??
'Field ID will be generated after this field is saved'
}
hasInputRightElement={Boolean(field._id)}
/>
{field._id ? (
<InputRightElement>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/features/admin-form/share/ShareFormModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export const ShareFormModal = ({
data-chromatic="ignore"
isReadOnly
value={shareLink}
hasInputRightElement={Boolean(formId)}
/>
{formId ? (
<InputRightElement>
Expand Down Expand Up @@ -314,6 +315,7 @@ export const ShareFormModal = ({
isReadOnly
isDisabled={isFormPrivate}
value={`${templateLink}`}
hasInputRightElement={Boolean(formId)}
/>
{formId ? (
<InputRightElement>
Expand Down Expand Up @@ -412,6 +414,7 @@ export const ShareFormModal = ({
setGoLinkHelperText(undefined)
}}
isReadOnly={goLinkSaved}
hasInputRightElement={goLinkSaved}
/>
{goLinkSaved ? (
<InputRightElement>
Expand Down
18 changes: 17 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { BuildOptions, defineConfig } from 'vite'
// @ts-expect-error missing type definitions
import nodePolyfills from 'vite-plugin-node-stdlib-browser'
import svgr from 'vite-plugin-svgr'
import tsconfigPaths from 'vite-tsconfig-paths'

const baseRollupOptions = {
// Silence Rollup "use client" warnings
// Adapted from https://github.com/vitejs/vite-plugin-react/pull/144
onwarn(warning, defaultHandler) {
if (
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
warning.message.includes('use client')
) {
return
}
defaultHandler(warning)
},
} satisfies BuildOptions['rollupOptions']

export default defineConfig(() => {
return {
build: {
outDir: '../dist/frontend',
emptyOutDir: true,
rollupOptions: {
...baseRollupOptions,
output: {
// Manually chunk datadog-chunk.ts so it gets preloaded in index.html instead of app.
manualChunks: {
'datadog-chunk': ['datadog-chunk.ts'],
},
},
logLevel: 'silent' as const,
},
},
base: './',
Expand Down

0 comments on commit 2998079

Please sign in to comment.