Gathering detailed insights and metrics for @pega/cosmos-react-core
Gathering detailed insights and metrics for @pega/cosmos-react-core
Gathering detailed insights and metrics for @pega/cosmos-react-core
Gathering detailed insights and metrics for @pega/cosmos-react-core
npm install @pega/cosmos-react-core
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
28
Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.
The recommended approach for using Cosmos is individual component imports to bundle with a method of your choosing.
1import ReactDOM from 'react-dom'; 2import { SomeComponent } from '@pega/cosmos-react-core'; 3 4ReactDOM.render(<SomeComponent {...props} />, el);
Cosmos adheres to the following code style guides:
These are enforced by ESLint, Prettier and Stylelint with settings some overridden/ignored. If you feel a certain coding style is better suited this project or should be allowed please speak up and advocate. Shoot for consistency and cleanliness.
With that, please take a moment to setup Visual Studio Code. We require the following extensions to be installed:
Cosmos will check the format of your code and fail builds on linting errors so best to have your workspace in sync as you go. Next...
Clone Cosmos:
1$ git clone https://github.com/pegasystems/cosmos-react.git
Install node_modules:
1$ npm i
Start Cosmos dev server to run Storybook:
1$ npm run start:stories
Create your first component - Component names must capitalized, containing only letters:
1$ npm run create:component name:YourComponent [type:fn(default)|class|ref] [test:false(default)|true]
This cmd will generate a directory at /packages/cosmos-core/components/YourComponent/ with the following files:
YourComponent.tsx
- A React component populated with some basic boilerplateYourComponent.stories.tsx
- A file used for the Storybook documentation that will hold demo componentsYourComponent.test.ts
- An empty file to use for test code, optionalindex.ts
- An index file that will re-export the default export from your component fileInside YourComponent.tsx
will be some initial boilerplate:
1import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react'; 2import styled from 'styled-components'; 3 4import { BaseProps, ForwardProps, PropsWithDefaults } from '../../types'; 5import { defaultThemeProp } from '../../theme'; 6 7export interface YourComponentProps extends BaseProps { 8 ref?: Ref<HTMLDivElement>; 9} 10 11type YourComponentPropsWithDefaults = PropsWithDefaults<YourComponentProps>; 12 13const StyledYourComponent = styled.div<YourComponentPropsWithDefaults>``; 14 15StyledYourComponent.defaultProps = defaultThemeProp; 16 17const YourComponent: FunctionComponent<YourComponentProps & ForwardProps> = forwardRef( 18 (props: PropsWithoutRef<YourComponentProps>, ref: Ref<HTMLDivElement>) => { 19 return <StyledYourComponent ref={ref} {...props} />; 20 } 21); 22 23export default YourComponent;
The YourComponent.stories.tsx
file will provide a hot reloading dev environment in Storybook:
1import YourComponent from './YourComponent'; 2 3// These are settings that storybook will use to render your component's stories 4export default { 5 title: 'Components/YourComponent', 6 component: YourComponent 7}; 8 9// This is the first story in your component's story book section 10export const firstYourComponent = () => <YourComponent>Hello YourComponent</YourComponent>;
No vulnerabilities found.
No security vulnerabilities found.