Gathering detailed insights and metrics for @clubmed/trident-ui
Gathering detailed insights and metrics for @clubmed/trident-ui
Gathering detailed insights and metrics for @clubmed/trident-ui
Gathering detailed insights and metrics for @clubmed/trident-ui
npm install @clubmed/trident-ui
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
14
3
59
React UI components is a library of reusable components for building web applications using the Club Med brand guidelines.
1npm install --save @clubmed/trident-ui react react-dom @react-spring/web 2npm install --save-dev tailwindcss postcss autoprefixer
This package exports a tailwind.preset
file that you can use to extend your own configuration.
Edit your tailwind.config.ts
file and add the following line:
1import type { Config } from 'tailwindcss'; 2import { tailwindPreset } from '@clubmed/trident-ui/tailwind'; // add this line 3 4const config = { 5 presets: [tailwindPreset as unknown as Config], 6 content: [ 7 './doc/**/*.mdx', 8 './lib/**/*.{ts,tsx,mdx}', // adapt this line to your project 9 '**/node_modules/@clubmed/trident-ui/**/*.js', 10 ], 11} satisfies Config; 12 13export default config;
Note: If you have a TypeScript issue when you import the
tailwind.preset
file, you can add the following line in yourtsconfig.json
file:
1{ 2 "include": ["tailwind.config.ts"] 3}
Then you have to configure your postcss.config.cts
file to use the tailwind.config.ts
file:
1module.exports = { 2 plugins: { 3 tailwindcss: {}, 4 autoprefixer: {}, 5 }, 6};
Then add the styles to your index.css
file:
1@import '@clubmed/trident-ui/style.css';
or in your main.tsx
file:
1import '@clubmed/trident-ui/style.css';
You can import any components directly from is directory. For example the Button component can be imported and used as follows:
1import { useState } from 'react'; 2import { Button } from '@clubmed/trident-ui/molecules/Buttons/Button'; 3 4export function App() { 5 const [count, setCount] = useState(0); 6 7 return ( 8 <> 9 <Button onClick={() => setCount((count) => count + 1)}>count is {count}</Button> 10 </> 11 ); 12}
you can use the TridentUIConfigProvider
to configure some option of the Trident UI library:
1import './index.css'; 2import App from './App'; 3import React from 'react'; 4import { createRoot } from 'react-dom/client'; 5import { TridentUIConfigProvider } from '@clubmed/trident-ui'; 6import { IconsProvider } from '@clubmed/trident-ui/atoms/Icons/contexts/IconsContext.js'; 7import Actions from '@clubmed/trident-ui/atoms/Icons/svg/Actions'; 8 9const baseName = (window as any).basename || '/'; 10 11createRoot(document.getElementById('root')!).render( 12 <React.StrictMode> 13 <TridentUIConfigProvider 14 value={{ 15 locale: 'fr-FR', 16 }} 17 > 18 <IconsProvider icons={[Actions]}> 19 <App /> 20 </IconsProvider> 21 </TridentUIConfigProvider> 22 </React.StrictMode>, 23);
locale
- The locale to use for the components. Default to fr-FR
.Trident UI provide a new way to load icons. You can use the IconProvider
component to load icons from a specific group.
Currently, there is two icons provider available:
For each provider, you have subset of icons split by groups name:
By default, no icons provider is set. You have to import a subset icons in your code as follows:
Svg mode:
1import Actions from '@clubmed/trident-ui/atoms/Icons/svg/Actions'; // load only the Actions subset using SVG mode 2import { Icon } from '@clubmed/trident-ui/atoms/Icons/Icon'; 3 4function App() { 5 return ( 6 <IconsProvider icons={[Actions]}> 7 <Icon name="ArrowDefaultLeft" /> 8 </IconsProvider> 9 ); 10}
You can mix usage of SVG and SVG-use modes:
1import Actions from '@clubmed/trident-ui/atoms/Icons/svg-use/Actions'; // load the Actions subset 2import Brand from '@clubmed/trident-ui/Icons/svg/Brand'; 3 4function App() { 5 return ( 6 <IconsProvider icons={[Actions, Brand]}> 7 <Icon name="ArrowDefaultLeft" /> 8 <Icon name="ClubMed" /> 9 </IconsProvider> 10 ); 11}
In this case, Icon component will automatically use the appropriate IconResolver to load and display the icon.
Trident UI provide function to register any external Svg icons without having redevelop
a custom Icon component. Just use resolver
from SvgIconResolver
or SvgUseIconResolver
to add your new icon:
1import { resolver } from '@/atoms/Icons/svg/SvgIconResolver'; 2 3const CustomIcons = resolver([ 4 { 5 name: 'MyCustomIcon', 6 group: 'custom', 7 element: lazy(() => import('./MyCustomIcon.svg?react')), 8 // viewBox: '0 0 30 30', // default '0 0 30 30' 9 // aspectRatio: 1, // default '1' 10 // orientation: 'left' // apply rotation to the icon 11 }, 12]); 13 14function App() { 15 return ( 16 <IconsProvider icons={[CustomIcons]}> 17 <Icon name="MyCustomIcon" /> 18 </IconsProvider> 19 ); 20}
The project have a builder to compile svg to font. Just add Svg inside atoms/Icons/svg
then
run the following command:
1npm run build:fonts
Currently, some icons in Font mode aren't correctly rendered because the SVG source aren't correctly cleaned.
if you are using Jest, you can add the following configuration to your jest.config.js
file:
1{ 2 moduleNameMapper: { 3 "^@clubmed/trident-ui/(.*)$": dirname(require.resolve("@clubmed/trident-ui")) + "$1" 4 }, 5 // add also this line can solve issue: 6 transformIgnorePatterns: ["/node_modules/(?!@clubmed/trident-ui)/.*"] 7}
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Copyright 2024 - Today | Club Med
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
No vulnerabilities found.
No security vulnerabilities found.