550 Commits

Author SHA1 Message Date
Lebaud Antoine
76ad5621c6 🐛(react) fix calendar selects initialization and syncing
Select under the calendar component were not properly initialized,
leading to issues. Additionally, syncing the dropdowns with the calendar
state was causing unnecessary renders. Selects now update on user events
triggered by the toggle button, ensuring the selected item remains
up-to-date. The code has been refactored to eliminate duplication
and improve the component's readability and maintainability.
2023-06-16 17:13:35 +02:00
Lebaud Antoine
10fa71e2a7 (react) add DatePicker component
Based on the Figma DS design by Alex, a mono date-picker
component has been added. It uses react-aria headless ui
component capabilities, with downshift headless ui component.
React-aria was not supporting by default dropdown menus to
select months and years. We could not reuse Popover component
from react-aria because we are not using their headless ui
component for the button one. Clicking on the toggle calendar
button triggers both the button and the popover click outside
events. React-aria button uses a custom onPress props that is
disabled by their popover. Instead, I have implemented a simple
custom hook. This is the first acceptable version of the component.
Some minor user interaction are missing. This first component
doesn't support time selection.
2023-06-12 18:57:20 +02:00
Lebaud Antoine
1d1cf81cf6 (react) add a popover component
A design system needs a popover mecanism.
In the select component, this logic is handled by downshift.
We introduce a new component, responsible to open an element in
a popin and close it when the user click outside of it.
2023-06-12 18:57:20 +02:00
Lebaud Antoine
f967775fb6 (react) compute a range of numbers
A new utils function has been added that would allow
developpers to easily compute a range between two
number, with a step of one. This function is inspired
by the python range function.
2023-06-12 18:57:20 +02:00
Lebaud Antoine
60ff04c2d9 📦️(react) add react-aria dependecies
Working on the date picker, we looked for an headless
UI components library. React-aria was chosen to support
the new form's component development. They developped a suite of
headless UI components that seemed quite easy to style.
2023-06-12 18:57:20 +02:00
Lebaud Antoine
6f05995f24 🎨(react) make eof stylesheets consistent
Some older tools misbehave if the last line of data
in a text file is not terminated with a newline.
It makes sure the last line was properly terminated.
2023-06-12 17:08:01 +02:00
Lebaud Antoine
59cf5de66d 📝(react) add missing design tokens on Select's documentation
Design tokens documented in the Select docs should match the available tokens.
This modification offer an exhaustive and complete list of the design
tokens available to customize the select component.
2023-06-12 16:29:26 +02:00
Nathan Vasse
0ad71a8ec1 ♻️((react) migrate DataGrid faker usages to new API
We forgot to migrate those stories when upgrading faker.
2023-06-06 17:10:33 +02:00
Nathan Vasse
787bd3de75 🏷️(react) allow autocompletion for DataGrid's renderCell
Previously the type of the row parameter of renderCell was hardcoded as
Row. This wasn't ideal because the best case scenario we want it to enable
Typescript to use the type of rows props. Now that's the case.

Resolve #62
2023-06-06 17:10:33 +02:00
Nathan Vasse
9127fd803c 🐛(react) support nested field in DataGrid
It was previously needed to use renderCell to be able to use nested
fields, which was not handy.

Resolve #62
2023-06-06 17:10:33 +02:00
Lebaud Antoine
1ff37cf12f 💄(react) improve input component styling configuration
Align design tokens of input component with select component's
design tokens for consistent styling configuration. Having a
transparent background was causing a weird ux.
2023-06-06 12:21:41 +02:00
Lebaud Antoine
38538e354b 💄(react) improve radio input styling configuration
Align design tokens of radio input component with select component's
design tokens for consistent styling configuration.
2023-06-06 12:21:41 +02:00
Lebaud Antoine
8cf2bb28e1 ♻️(react) improve checkbox styling configuration
Align design tokens of checkbox component with select component's
design tokens for consistent styling configuration.
2023-06-06 12:21:41 +02:00
jbpenrath
a0d737aaf8 🍱(react) add storybook favicon
We recently customized Storybook documentation to brand it to Cunningham
 but we forgot to change the favicon.
2023-06-02 11:00:58 +02:00
Lebaud Antoine
fe91471127 💄(react) improve DX when converting px to rem values
It can be tricky, while integrating the figma design file,
to map some small px values to their rem equivalent. Thus,
this PR proposes a new util function converting pixel to rem.
It would ensure that all size values can scale base on the
font-size base, while keeping a good developer experience.
2023-06-01 19:20:05 +02:00
jbpenrath
aa4dcdd800 (react) fix flaky test about Input component
A test of Input component was flaky and raise some `act` warnings.
Forcing the use of testing library 9 seems to fix the issue.
2023-06-01 18:00:36 +02:00
jbpenrath
7144961c50 🍱(react) fix storybook logo link
The storybook logo was broken on the production website. Indeed the link
 was prefixed by a slash.
2023-06-01 18:00:36 +02:00
Nathan Vasse
0153b5043b 📝(react) add forms examples to documentation
We think doing this really illustrates what the design system looks
in real life, all components living together next to each other.
2023-06-01 12:05:32 +02:00
Nathan Vasse
2c6a66b220 💄(react) change pagination border color
The pagination component's border color was different from the one
of other components, especially the DataGrid, which was not really
homogenous.
2023-06-01 12:05:32 +02:00
Nathan Vasse
a869fe51dc 💄(react) reduce inputs borders
We do this in order to have homogenous border accross the entire
library, before we had DataGrid with 1px border and inputs with 2px
borders, which was not really nice to the eye.
2023-06-01 12:05:32 +02:00
Nathan Vasse
1cb1b48c8d (react) add min-width to Field
Without this new property the components using Field ( Input, Select, ... )
would not properly fit by default inside a flex parent.
2023-06-01 12:05:32 +02:00
Nathan Vasse
30d08a956b (react) add fullWidth props to Button
Can be useful in many situations.
2023-06-01 12:05:32 +02:00
jbpenrath
d767d61dd2 📝(react) customize storybook theme
We want to customize our Storybook to market it for Cunningham.
2023-05-31 14:31:53 +02:00
Nathan Vasse
cfdac8dba9 💄(react) migrate to Roboto Flex
Previously we were using standard Roboto Font but we were struggling to
get the same boldness as the ones from the Figma sketches. It appears
that Figma uses Roboto Flex, so by installing it we can now nearly
perfectly align our visuals with the ones form the sketches. I had to
do some custom tweaks with the weights of the font because if we
use exactly the same font-weight as in Figma the render is still different.
2023-05-26 16:39:02 +02:00
Nathan Vasse
bc4638de41 👽️(react) add material-icons class
The upgrade of @fontsource to v5 forces us to include the .material-icons
class on our side.
2023-05-26 16:39:02 +02:00
renovate[bot]
1eda301637 ⬆️(dependencies) update js dependencies 2023-05-26 16:39:02 +02:00
Nathan Vasse
22ad673374 🔖(release) version packages
Bump @openfun/cunningham-react to 0.7.0
2023-05-24 17:10:23 +02:00
Nathan Vasse
ef4ece39b4 🐛(react) fix label color on state disabled ( select, input )
When creating LabelledBox we introduced a bug than overrides the label
colors when inputs are disabled.
2023-05-24 16:49:49 +02:00
Nathan Vasse
bc6d085868 💄(react) change label color on state error ( select, input )
We forgot to implement this during the first PRs.
2023-05-24 16:49:49 +02:00
Nathan Vasse
75c6e2e482 💄(react) change label color when focused ( select, input )
We forgot to implement this behavior when coding these inputs.
2023-05-24 16:49:49 +02:00
Nathan Vasse
d79f01fd93 (react) add the possibility to hide select label
Based on recent feedbacks this feature was needed. It is important for
the label to still be accessible to screen readers, that's why we
introduced the offscreen class.

Resolve #60
2023-05-24 15:58:07 +02:00
Nathan Vasse
c93c8d2a2f (react) add disable property to select option
Based on recent feedbacks, this feature was needed for consumer apps.

Resolve #60
2023-05-24 15:58:07 +02:00
Nathan Vasse
c11727976c (react) add clearable option to Select
Based on a feedback given from another project, we want to be able
to disable the clear feature on the select.

Resolve #60
2023-05-24 15:58:07 +02:00
Nathan Vasse
9065d6c87b 💄(react) change success text color to comply with RGAA
Previsouly we were not matching the 4.5:1 contrast.
2023-05-24 15:37:50 +02:00
Nathan Vasse
9d7ad489ba (react) add Switch component
Implement a shiny new component that can be used as an alternative to
the regular checkbox.
2023-05-24 15:37:50 +02:00
Nathan Vasse
ec8def0cb1 🐛(react) fix Field that can be compact and fullWidth
Being able to define the Field to be compact and fullWidth at the
same time was misleading. We need to be able to set the Switch
component fullWidth if needed, while by default it is compact. This
change makes possible the fullWidth props to override compact mode.
2023-05-24 15:37:50 +02:00
Nathan Vasse
e72606cfcd 💄(react) make inputs labels bolder
The current labels of radio, checkbox and switches were not bold enough
to match the figma sketches.
2023-05-24 15:37:50 +02:00
Nathan Vasse
eb6692bf5e (react) add a design token for checkbox hover background
This was based on recent feedbacks to provide more granularity for
customization.

Resolve #59
2023-05-24 12:00:42 +02:00
Nathan Vasse
527c3fc0c9 (react) set specific cursor on checkbox related components
Even if this is not the default behavior of the native checkbox, based on
recent feedbacks and by comparing what other components libraries do, it
appears that setting a custom cursor on checkbox hover is the most
intuitive thing to do.

Resolve #59
2023-05-24 12:00:42 +02:00
Nathan Vasse
6f77131839 ♻️(react) migration preview.js to preview.ts
Storybook 7 allows to simply use typing inside preview.ts configuration file.
2023-05-24 11:10:13 +02:00
Nathan Vasse
c53d34834c 📝(react) add customization doc
This part of the doc was a huge miss as it is often asked during
installation based on our recent feedbacks.
2023-05-24 11:10:13 +02:00
Nathan Vasse
e05c6b786c 🏷️(react) export DefaultToken types and defaultTokens variable
By doing this we provide more typings for consumers which makes more
handy the use of the local configuration in cunningham.ts files.
2023-05-24 11:10:13 +02:00
Nathan Vasse
b5fcfdfeab (react) add support for CJS
At first we wanted to only support ESM. But as we want to share types
and export design tokens from the react package to the outside world
in order to allow local cunningham.ts files to import them, we are
forced to also build the library for CJS too. Why? Because local
cunningham.ts files are loaded as CJS, so they can only import CJS
module. Why loading cunningham.ts as CJS? Because the tokens package's
binary is built for CJS, then it's seamless to make it load CJS, where
making it load ESM was buggy. And why not migrate the tokens package to
ESM so? Because it implies to rewrite every imports with .js extensions,
makes us loose the possibility to use __dirname kind of variables. And
also Jest use for testing is not compliant at all when it comes to execute
ESM code. Well, the ecosystem is not ready for that at the moment, sadly.
2023-05-24 11:10:13 +02:00
Nathan Vasse
bc15ced92f ♻️(react) rename docs to new format
Previously we were using .stories.mdx extension for docs but now
.mdx is the most recommend extension according to official Storybook
7 documentation.
2023-05-24 11:10:13 +02:00
Nathan Vasse
ce6eb50a98 ♻️(react) migrate ArgsTable to ArgTypes and rework imports
Storybook was emitting warnings errors about the fact that ArgsTable
is deprecated, and also I rewrote imports as those are not the one
used in the doc anymore, this will prevent breaking changes in the
upcoming upgrades.
2023-05-23 10:10:40 +02:00
Nathan Vasse
8cda41772d ♻️(react) fix Storybook source blocks
Due to the recent upgrade to Storybook 7, the source blocks of Canvases
were broken, they were only showing args. This was mainly due to the fact
that as of Storybook 7 the meta tags of the MDX files have changed, thus
causing the issue. These are now based on imports. We also needed to rename
index.stories.mdx files to index.mdx because Storybook was throwing errors,
maybe due to a conflicts with index.stories.tsx files and new imports.
Anyway this way of naming MDX files seems to be the recommend one based on
the official documentation.
2023-05-23 10:10:40 +02:00
Nathan Vasse
f264c29a4a 🔖(release) version packages
Bump @openfun/cunningham-react to 0.6.2
2023-05-15 17:28:18 +02:00
Nathan Vasse
15eb9b9e57 🏷️(react) add missing types exports
We forgot to add exports for Checkbox and Radio.
2023-05-15 17:23:49 +02:00
Nathan Vasse
dd89157654 🐛(react) fix storybook deploy
The static storybook deployment to github pages was throwing 404 errors
for a file beginning with a underscore, adding a .nojekyll disables
conflicts due to the default behavio of github pages.
2023-05-15 15:07:49 +02:00
Nathan Vasse
424fa05cca 🔧(react) migrate storybook deployment to version 7
The package @storybook/storybook-deployer that seems to not directly work
with Storybook 7 was expecting that command named "build-storybook" to
exist. With the bin updates of Storybook 7 this bin does not longer exist,
so I created a specfic script inside package.json that is named
"build-storybook" too in order to make everything work. Also now that
Storybook uses directly the local vite config, the fact that our config
generates types was causing issues when building Storybook, that why
we filter plugins in main.ts in order to remove "vite:dts".
2023-05-15 11:04:06 +02:00