Skip to content

Commit

Permalink
feat: [M3-8170] - Add CheckoutBar Story (#10784)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmakode-akamai authored Aug 23, 2024
1 parent 15e3506 commit 43366ac
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
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>,
},
};
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

0 comments on commit 43366ac

Please sign in to comment.