Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@equinor/echo-components
Advanced tools
This publishable library was generated with [Nx](https://nx.dev).
This publishable library was generated with Nx.
Building blocks for Echo, built on top of EDS (Equinor Design System).
Think of Storybook as a virtual showroom for your app's building blocks - the UI components. It lets developers experiment with components in isolation, like tinkering with Legos before building something bigger. Storybook isn't just about documenting components, it's about creating an interactive playground for developers to explore their full potential.
Publishing static storybook page
echo-components-storybook
- we shouldn't delete this one!Online storybook can be found here
Imagine a button component - the workhorse of applications. Here's how to craft a compelling story around it:
Ingredients:
Step 1. Set the Stage: Configuration and Title (Meta): Define the Meta object with:
import { Meta, StoryFn } from '@storybook/react';
import { Button } from './Button'; // Replace with your Button component import path
const meta: Meta<typeof Button> = {
title: 'Components/Button/Button', // Descriptive title for Storybook navigation
component: Button,
args: {
as: 'button', // Default element type (can be overridden as 'span' or 'a')
},
argTypes: {
as: {
options: ['span', 'a', 'button'], // Available options for the 'as' prop
control: {
type: 'select', // Control type for selecting the 'as' prop in Storybook UI
},
},
},
parameters: {
docs: {
page: './Button.docs.mdx', // Path to your button documentation file (replace if needed)
},
},
};
export default meta;
Step 2. Create the Template: Write a reusable Template function that renders the component within a container element (e.g., div). This template will be used in most stories.
const Template: StoryFn<Button.Props> = (args) => (
<div className="button-container"> {/* Add a container class for styling (optional) */}
<Button {...args} />
</div>
);
Step 3. Tell the Main Story: Introduction:
export const Introduction: StoryFn<Button.Props> = () => (
<Template>You can control me</Template>
);
Step 4. Spice it Up: Variations and States: Create additional stories to demonstrate different button variations and states. These could be:
export const PrimaryButtonLarge: StoryFn<Button.Props> = () => (
<Template>
<Button variant="primary" size="large">
Large Primary Button
</Button>
</Template>
);
export const DisabledButton: StoryFn<Button.Props> = () => (
<Template>
<Button disabled>Click Me (Disabled)</Button>
</Template>
);
export const LoadingButton: StoryFn<Button.Props> = () => (
<Template>
<Button isLoading>Loading...</Button>
</Template>
);
export const IconButton: StoryFn<Button.Props> = () => (
<Template>
<Button variant="icon">
<Icon name="search" /> {/* Assuming you have an Icon component */}
</Button>
</Template>
);
Step 5. Visual Presentation (Optional): Consider using background colors or layouts to enhance the visual appeal of your stories. Example: You can customize the button-container class in the Template to add background colors or styles for a more visually appealing presentation.
Step 6. Serve it Up! (Export): Export the meta object (containing configuration) at the end of your file..
export default meta;
Check the readme in the NX libraries folder.
lint-components
build-components
test-components
Keeping it for historical reasons. https://github.com/equinor/EchoComponents
Composition
When deciding how to write your new component consider the composition. Using smaller interchangeable components that each represent a specific function or feature in the context of a larger component. Using wrapper components in conjunction with the children
property, allows for a greater separation of concerns, smaller blocks of code and a greater level of customization in the final product.
<Card.Container> {/* REQUIRED */}
<Card.Image src="hello_world.jpg"> {/* INTERCHANGEABLE */}
<Card.Caption>Descriptive text</Card.Caption> {/* INTERCHANGEABLE */}
<Card.Heading>Heading</Card.Heading> {/* INTERCHANGEABLE */}
<Card.Ingress>Subtitle/Ingress</Card.Ingress> {/* INTERCHANGEABLE */}
<Card.Article>Main content</Card.Article> {/* INTERCHANGEABLE */}
</Card.Image>
</Card.Container>
The makeup of each component may vary depending on the feature and the problem being solved. Some components may not be interchangeable, and some components may need additional props.
Abstracting the individual composition should be possible, by creating a new component in the project that can act as a bootstrapping mechanism for the EchoComponent composition.
import React from 'react';
type Props = {
heading: string;
mainContent: string;
imageSrc?: string;
imageCaption?: string;
ingress?: string;
};
export const ExampleCard: React.FC<Props> = ({ heading, mainContent, imageSrc, imageCaption, ingress }) => {
return (
<Card.Container>
<Card.Image src={imageSrc}>
{imageCaption && <Card.Caption>{imageCaption}</Card.Caption>}
<Card.Heading>{heading}</Card.Heading>
{ingress && <Card.Ingress>{ingress}</Card.Ingress>}
<Card.Article>{mainContent}</Card.Article>
</Card.Image>
</Card.Container>
);
};
export default ExampleCard;
children
and className
.className
should always be included, to allow for custom styling when needed. (see point 6. for more information on custom styling)FAQs
This publishable library was generated with [Nx](https://nx.dev).
The npm package @equinor/echo-components receives a total of 168 weekly downloads. As such, @equinor/echo-components popularity was classified as not popular.
We found that @equinor/echo-components demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.