### Install Dependencies and Run Dev Server
Source: https://github.com/razorpay/blade/blob/master/packages/blade-mcp/base-blade-template/README.md
Use these commands to install project dependencies and start the development server.
```sh
npm install # to install dependencies
```
```sh
npm run dev # to run the dev server
```
--------------------------------
### Motion React Installation and Setup
Source: https://github.com/razorpay/blade/blob/master/packages/blade/src/components/BaseMotion/docs/MotionIntro.mdx
This section covers the installation and setup process for Motion React. It includes an alert for users who may have already completed parts of the setup.
```javascript
import { Meta } from '@storybook/addon-docs/blocks';
import {
Alert,
Text,
Accordion,
AccordionItem,
AccordionItemHeader,
AccordionItemBody,
Heading,
Box,
Move,
Display,
Divider,
} from '../../index';
import { Motion as MotionTokensTable } from '../../../../docs/tokens/Motion.mdx';
import MotionInstallation from './MotionInstallation.mdx';
import { Showcase } from './MotionIntroUtils';
import {
FadeIntro,
MoveIntro,
SlideIntro,
ScaleIntro,
ElevateIntro,
MorphIntro,
StaggerIntro,
AnimateInteractionsIntro,
} from './introExamples';
Introduction to Motion Presets at Razorpay
[Motion Presets RFC](https://github.com/razorpay/blade/blob/master/rfcs/2024-08-21-motion-presets.md)
We offer several easy-to-use motion presets to simplify integrating motion in your projects. This doc is one-stop documentation for everything related to motion presets. Checkout stories of individual motion components from storybook's sidebar to learn in details about each preset.
Motion React Installation and Setup 📚Motion Preset Components ✨1. Fade
The Fade component is a motion preset that animates the opacity of its children, allowing them to smoothly appear or disappear. It ensures seamless transitions while keeping the UI visually engaging.
2. Move
The Move component is a motion preset that animates the opacity and position of its children,
allowing them to smoothly appear or disappear. It ensures seamless transitions while keeping the
UI visually engaging.
3. Slide
The Slide component is a motion preset that animates the children by sliding them in from
outside of viewport, allowing them to smoothly appear or disappear. Unlike Move, Slide is meant
to animate components from outside of viewport
7. AnimateInteractions
AnimateInteractions is a component that allows you to animate child components based on
interactions on parent. This is similar to doing `.parent:hover .child {}` styling in CSS.
```
--------------------------------
### Motion Installation Documentation
Source: https://github.com/razorpay/blade/blob/master/packages/blade/docs/guides/Installation.mdx
Include the MotionInstallation documentation. This is typically used for providing detailed setup instructions for motion-related components.
```mdx
import MotionInstallation from '../../src/components/BaseMotion/docs/MotionInstallation.mdx';
```
--------------------------------
### Implement a Basic Guided Tour with Custom Footer
Source: https://github.com/razorpay/blade/blob/master/packages/blade-mcp/knowledgebase/components/SpotlightPopoverTour.md
This example demonstrates a simple guided tour with three steps. It uses a custom footer component to control navigation between steps, allowing for 'Next', 'Prev', and 'Done' actions.
```tsx
import {
SpotlightPopoverTour,
SpotlightPopoverTourStep,
SpotlightPopoverTourFooter,
Box,
Button,
Text,
Card,
CardBody,
InfoIcon,
Amount,
} from '@razorpay/blade/components';
import type {
SpotlightPopoverTourSteps,
SpotlightPopoverStepRenderProps,
} from '@razorpay/blade/components';
import { useState } from 'react';
// Custom footer component that can control the tour
const CustomTourFooter = ({
activeStep,
totalSteps,
goToNext,
goToPrevious,
stopTour,
}: SpotlightPopoverStepRenderProps): React.ReactElement => {
const isLast = activeStep === totalSteps - 1;
const isFirst = activeStep === 0;
return (
);
};
function BasicTourExample(): React.ReactElement {
const [activeStep, setActiveStep] = useState(0);
const [isOpen, setIsOpen] = useState(false);
// Define the tour steps
const steps: SpotlightPopoverTourSteps = [
{
name: 'refunds-step',
title: 'Overview of Refunds',
content: () => (
You can issue refunds for various reasons, like when a customer returns a product or
cancels a service.
You can also issue partial refunds - for example, if a customer purchased multiple
items.
),
placement: 'bottom' as const,
footer: CustomTourFooter,
},
{
name: 'disputes-step',
title: 'Overview of Disputes',
content: () => (
Disputes are raised by customers when they have a problem with a transaction.
),
placement: 'bottom' as const,
footer: CustomTourFooter,
},
{
name: 'status-step',
title: 'Dispute Statuses',
content: () => (
Disputes which are open or under review will be shown here. You can also review them by
clicking on the button.
),
placement: 'bottom' as const,
footer: CustomTourFooter,
},
];
return (
{
setActiveStep(0);
setIsOpen(false);
}}
onOpenChange={({ isOpen }) => {
setIsOpen(isOpen);
}}
onStepChange={(step) => {
setActiveStep(step);
}}
>
Refunds3 ProcessedDisputes {
setIsDeleteLoading(true);
try {
// Simulate API call
await new Promise((resolve) => setTimeout(resolve, 1000));
setIsDeleteOpen(false);
} finally {
setIsDeleteLoading(false);
}
};
return (
setIsDeleteOpen(false)}
type="negative"
icon={TrashIcon}
title="Delete Account?"
description="This action cannot be undone. All of your data will be permanently deleted. This includes your profile, settings, and all associated information."
primaryButtonText="Delete Account"
secondaryButtonText="Cancel"
onConfirm={handleDelete}
isLoading={isDeleteLoading}
/>
setIsSwitchOpen(false)}
type="neutral"
image="https://logo.svgcdn.com/d/woocommerce-plain-wordmark.svg"
title="Switch to WooCommerce?"
description="Switching platforms will reset your current settings. Your existing data will be preserved but you'll need to reconfigure your platform-specific settings."
primaryButtonText="Switch Platform"
secondaryButtonText="Stay Here"
onConfirm={() => setIsSwitchOpen(false)}
/>
setIsTourOpen(false)}
type="positive"
icon={MapIcon}
title="Start Product Tour?"
description="Take a guided tour of our platform's key features. Learn how to make the most of our tools and improve your workflow."
primaryButtonText="Start Tour"
secondaryButtonText="Maybe Later"
onConfirm={() => setIsTourOpen(false)}
/>
);
};
export default ConfirmationExample;
```
--------------------------------
### Install Dependencies
Source: https://github.com/razorpay/blade/blob/master/packages/plugin-figma-blade-coverage/README.md
After cloning the repository, run this command to install all necessary project dependencies.
```bash
yarn install
```
--------------------------------
### Start Development Server
Source: https://github.com/razorpay/blade/blob/master/packages/plugin-figma-blade-coverage/README.md
Run this command to start the development server, which will watch for changes and rebuild the plugin.
```bash
yarn watch
```
--------------------------------
### React Router Setup for Mobile App Example
Source: https://github.com/razorpay/blade/blob/master/packages/blade-mcp/knowledgebase/components/BottomNav.md
This snippet demonstrates how to wrap a React component with BrowserRouter to enable routing for a complete mobile app example.
```javascript
import React from 'react';
import {
BrowserRouter,
} from 'react-router-dom';
// Wrap with router for complete example
const App = () => (
);
export default App;
```
--------------------------------
### Install iOS Pods
Source: https://github.com/razorpay/blade/blob/master/CONTRIBUTING.md
Navigate to the `ios/` directory and run `pod install` to install the necessary pods for the iOS project. This command is for Intel machines; M1 users may need to follow specific notes.
```sh
pod install
```
--------------------------------
### Start iOS Storybook
Source: https://github.com/razorpay/blade/blob/master/CONTRIBUTING.md
Run this command in the `packages/blade` directory to start the Storybook development server for iOS. The app should be installed and launched on the simulator.
```sh
yarn start:ios
```
--------------------------------
### Promotional Toast Example
Source: https://github.com/razorpay/blade/blob/master/packages/blade/src/components/Toast/_decisions/decisions.md
Provides an example of how to display a promotional toast with custom content, an action button, and an icon.
```APIDOC
## POST /promotional-toast (Conceptual)
### Description
This example demonstrates how to create and display a promotional toast using the `useToast` hook. Promotional toasts are typically used for more significant announcements or actions.
### Method
Imperative API call via `useToast` hook.
### Endpoint
N/A (Client-side hook)
### Parameters
Refer to the `ToastProps` in the 'Toast Component Usage' section for detailed parameters. Key differences for promotional toasts include:
- **type**: Should be set to 'promotional'.
- **autoDismiss**: Defaults to `false`.
- **duration**: Defaults to `8000`ms.
### Request Example
```jsx
import { Button, Box, Heading, Text, DollarIcon } from '@razorpay/blade/components';
import { BladeProvider, ToastContainer, useToast } from '@razorpay/blade/components';
const Example = () => {
const toast = useToast();
return (
);
};
const App = () => {
return (
)
}
```
### Response
#### Success Response (200)
- **id** (string) - The unique identifier of the displayed toast.
```
--------------------------------
### ActionListHeader Examples
Source: https://github.com/razorpay/blade/blob/master/packages/blade/src/components/BottomSheet/_decisions/api-revision-1.md
Examples of how to use ActionListHeader with different configurations for title, leading icon, and variant styling.
```jsx
}
/>
```
--------------------------------
### Switch Component Examples
Source: https://github.com/razorpay/blade/blob/master/packages/blade/src/components/Switch/_decisions/decisions.md
Code examples demonstrating basic, controlled, and uncontrolled usage of the Switch component.
```APIDOC
## Switch Component Examples
### Basic Usage
```jsx
// basic
```
### Controlled Component
```jsx
const Controlled = () => {
const [checked, setChecked] = React.useState(false);
return (
setChecked(isChecked)}
value="dark-mode"
/>
);
};
```
### Uncontrolled Component
```jsx
const Uncontrolled = () => {
return (
console.log(isChecked)}
value="dark-mode"
/>
);
};
```
### Custom Label
Switch by default does not render a `