Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal component render #53

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ac40b3a
:heavy_plus_sign: Ensure we have the Formio.js types
sergei-maertens Dec 22, 2024
6e405d1
:sparkles: Initial super minimal render component
sergei-maertens Dec 22, 2024
20330e2
:sparkles: Start setting up registry
sergei-maertens Dec 22, 2024
2fb7d1c
:sparkles: Defer rendering a Formio component definition to the registry
sergei-maertens Dec 22, 2024
ea285fa
:sparkles: Have the fieldset component recurse its children
sergei-maertens Dec 22, 2024
ddba1bf
:sparkles: Copy over the TextField form component from the SDK
sergei-maertens Dec 22, 2024
dba8c5b
:sparkles: Wire up form component to formio render component
sergei-maertens Dec 22, 2024
e9c768f
:technologist: Deal with circular imports
sergei-maertens Dec 23, 2024
1dc6ebd
:arrow_up: Add @utrecht/components library and design tokens
sergei-maertens Dec 23, 2024
58d3395
:hammer: Set up sass support in Storybook
sergei-maertens Dec 23, 2024
44b3d53
:sparkles: Render Label component with OF theme
sergei-maertens Dec 23, 2024
0361046
:sparkles: Include NL DS styles for form fields
sergei-maertens Dec 23, 2024
0d276c5
:sparkles: Include SCSS overrides for validation errors from SDK
sergei-maertens Dec 23, 2024
c92bfd3
:lipstick: Include error styles for textfield validation errors
sergei-maertens Dec 23, 2024
5c6e83a
:rotating_light: Prettier
sergei-maertens Dec 23, 2024
5de3372
:sparkles: Scaffold top-level Form component
sergei-maertens Dec 23, 2024
df48972
:sparkles: Generically render the form fields
sergei-maertens Dec 23, 2024
5159848
:building_construction: Use container object for registry entry
sergei-maertens Dec 24, 2024
b50e19d
:label: Define JSON types
sergei-maertens Dec 24, 2024
768be3f
:sparkles: First pass at setting the initial Form state
sergei-maertens Dec 24, 2024
0cf2e95
:sparkles: Extract initial values from layout/nested components
sergei-maertens Dec 24, 2024
88be1ed
:lipstick: Implement proper layout and styling for fieldset
sergei-maertens Dec 24, 2024
1e92f16
:sparkles: Support placeholder on textfield component
sergei-maertens Dec 24, 2024
30efb07
:lipstick: Apply text input style overrides of Open Forms
sergei-maertens Dec 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .storybook/decorators.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type {Decorator} from '@storybook/react';
import {Formik} from 'formik';
import {CSSProperties} from 'react';

/**
* Wrap stories so that they are inside a container with the class name "utrecht-document", used
* to wrap some 'page-global' styling.
*/
export const utrechtDocumentDecorator: Decorator = Story => {
return (
<div
className="utrecht-document utrecht-document--surface"
style={
{
'--utrecht-document-font-size': '16px',
} as CSSProperties
}
>
<Story />
</div>
);
};

export const withFormik: Decorator = (Story, context) => {
const isDisabled = context.parameters?.formik?.disable ?? false;
if (isDisabled) {
return <Story />;
}
const initialValues = context.parameters?.formik?.initialValues || {};
const initialErrors = context.parameters?.formik?.initialErrors || {};
const initialTouched = context.parameters?.formik?.initialTouched || {};
const wrapForm = context.parameters?.formik?.wrapForm ?? true;
return (
<Formik
initialValues={initialValues}
initialErrors={initialErrors}
initialTouched={initialTouched}
enableReinitialize
onSubmit={(values, formikHelpers) => console.log(values, formikHelpers)}
>
{wrapForm ? (
<form id="storybook-withFormik-decorator-form" data-testid="storybook-formik-form">
<Story />
</form>
) : (
<Story />
)}
</Formik>
);
};
45 changes: 45 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type {StorybookConfig} from '@storybook/react-webpack5';
import CircularDependencyPlugin from 'circular-dependency-plugin';
import path from 'path';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';

const config: StorybookConfig = {
Expand All @@ -17,13 +19,56 @@ const config: StorybookConfig = {
'@storybook/addon-interactions',
'storybook-react-intl',
'@storybook/addon-webpack5-compiler-babel',
{
name: '@storybook/addon-styling-webpack',
options: {
rules: [
// Replaces existing CSS rules with given rule
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
// Replaces any existing Sass rules with given rules
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require.resolve('sass'),
sassOptions: {
quietDeps: true,
},
},
},
],
},
],
},
},
],
docs: {},
webpackFinal: async config => {
if (!config.resolve) {
config.resolve = {};
}
config.resolve.plugins = [new TsconfigPathsPlugin()];

if (!config.resolve.alias) {
config.resolve.alias = {};
}
config.resolve.alias['@/scss'] = path.resolve('src/scss');

if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(
new CircularDependencyPlugin({
failOnError: true,
})
);
return config;
},
};
Expand Down
3 changes: 3 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script defer>
document.documentElement.classList.add('openforms-theme');
</script>
6 changes: 6 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import '@open-formulieren/design-tokens/dist/index.css';
import {Preview} from '@storybook/react';
import '@utrecht/components/dist/document/css/index.css';

import {utrechtDocumentDecorator} from './decorators';

const preview: Preview = {
decorators: [utrechtDocumentDecorator],
parameters: {
controls: {
matchers: {
Expand All @@ -9,6 +14,7 @@ const preview: Preview = {
},
},
},
tags: ['private'],
};

export default preview;
Loading
Loading