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

feat: [M3-8170] - Add CheckoutBar Story #10784

Merged
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10784-added-1723651941893.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

CheckoutBar Story ([#10784](https://github.com/linode/manager/pull/10784))
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from 'react';

import { Typography } from 'src/components/Typography';

import { CheckoutBar } from './CheckoutBar';

import type { Meta, StoryFn, StoryObj } from '@storybook/react';

type Story = StoryObj<typeof CheckoutBar>;

const Item = ({ children }: { children?: React.ReactNode }) => (
<Typography sx={{ fontStyle: 'italic' }}>{children}</Typography>
);

const defaultArgs = {
calculatedPrice: 30.0,
children: <Item>Child items can go here!</Item>,
heading: 'Checkout',
onDeploy: () => alert('Deploy clicked'),
submitText: 'Submit',
};

const meta: Meta<typeof CheckoutBar> = {
argTypes: {
onDeploy: { action: 'onDeploy' },
},
component: CheckoutBar,
decorators: [
(Story: StoryFn) => (
<div style={{ margin: '2em' }}>
<Story />
</div>
),
],
title: 'Components/CheckoutBar',
};

export default meta;

export const Default: Story = {
args: defaultArgs,
};

export const WithAgreement: Story = {
args: {
...defaultArgs,
agreement: <Item>Agreement item can go here!</Item>,
},
};

export const Disabled: Story = {
args: {
...defaultArgs,
disabled: true,
},
};

export const Loading: Story = {
args: {
...defaultArgs,
isMakingRequest: true,
},
};

export const WithFooter: Story = {
args: {
...defaultArgs,
footer: <Item>Footer element can go here!</Item>,
},
pmakode-akamai marked this conversation as resolved.
Show resolved Hide resolved
};
34 changes: 34 additions & 0 deletions packages/manager/src/components/CheckoutBar/CheckoutBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,50 @@ import {
} from './styles';

interface CheckoutBarProps {
/**
* JSX element to be displayed as an agreement section.
*/
agreement?: JSX.Element;
/**
* Calculated price to be displayed.
*/
calculatedPrice?: number;
/**
* JSX element for additional content to be rendered within the component.
*/
children?: JSX.Element;
/**
* Boolean to disable the `CheckoutBar` component, making it non-interactive.
* @default false
*/
disabled?: boolean;
/**
* JSX element to be displayed as a footer.
*/
footer?: JSX.Element;
/**
* The heading text to be displayed in the `CheckoutBar`.
*/
heading: string;
/**
* Boolean indicating if a request is currently being processed.
*/
isMakingRequest?: boolean;
/**
* Callback function to be called when the deploy action is triggered.
*/
onDeploy: () => void;
/**
* Helper text to be displayed alongside the price.
*/
priceHelperText?: string;
/**
* Text to describe the price selection.
*/
priceSelectionText?: string;
/**
* Text for the submit button.
*/
submitText?: string;
}

Expand Down
Loading