### Basic Usage Example in Demo File
Source: https://github.com/shuyunff2e/cloud-react/blob/master/docs/demo.md
This snippet illustrates the typical content structure of a `*.markdown` demo file. It includes front matter (metadata like title and description), a React JSX component demonstrating basic button usage, and accompanying styling defined in either LESS or CSS. The example focuses on a simple use case for the `Button` component.
```jsx
import { Button } from 'cloud-react';
import React from 'react';
export default class BasicDemo extends React.Component {
render() {
return ;
}
}
```
```less
.btn {
a {
color: red;
}
}
```
```css
.btn a {
color: red;
}
```
--------------------------------
### Basic CDrawer Usage Example
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/c-drawer/demos/basic.md
This example demonstrates a fundamental implementation of the CDrawer component. It shows how to control the drawer's visibility using a button, manage its open/close state, and configure basic properties like title, placement, and event handlers.
```jsx
/**
* title: 基础
* desc: 头像有六种尺寸,两种形态
*/
import React from 'react';
import { Button, CDrawer } from 'cloud-react';
class Demo extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
};
}
showDrawer() {
this.setState({
open: true,
});
}
onClose() {
this.setState({
open: false,
});
}
render() {
return (
);
}
}
export default Demo;
```
--------------------------------
### Install Node.js Dependencies
Source: https://github.com/shuyunff2e/cloud-react/blob/master/README.md
This command installs all required Node.js dependencies for the cloud-react project using npm. It fetches packages listed in the project's package.json file.
```bash
$ npm i
```
--------------------------------
### Start Development Server
Source: https://github.com/shuyunff2e/cloud-react/blob/master/README.md
This command initiates the local development server for the cloud-react project. It's used for live development, testing changes, and typically includes hot-reloading capabilities.
```bash
$ npm start
```
--------------------------------
### Component Demo File Directory Structure
Source: https://github.com/shuyunff2e/cloud-react/blob/master/docs/demo.md
Illustrates the recommended directory structure for placing component demo files within the `src/components` directory. Each component should have a `demos` subdirectory containing its markdown demo files, such as `basic.markdown`.
```javascript
|- src
|- components
|- button
|- demos
|- basic.markdown
```
--------------------------------
### React CCascader Component Basic Usage
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/c-cascader/demos/transition.md
This JSX code snippet demonstrates how to use the `CCascader` component from the `cloud-react` library. It initializes the component with static address options, sets a placeholder text, and applies a 'slide-up' transition effect for its dropdown. The example showcases a typical setup for a cascader selection input in a React application.
```jsx
import React from 'react';
import { CCascader } from 'cloud-react';
const addressOptions = [
{
value: 'zhejiang',
label: 'ZhejiangZhejiangZhejiangZhejiangZhejiangZhejiangZhejiangZhejiangZhejiangZhejiangZhejiangZhejiang',
children: [
{
value: 'hangzhou',
label: 'Hangzhou',
children: [
{
value: 'xihu',
label: 'West Lake',
},
{
value: 'xiasha',
label: 'Xia Sha',
},
],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [
{
value: 'zhonghuamen',
label: 'Zhong Hua men',
},
],
},
],
},
];
export default function Demo() {
return (
);
}
```
--------------------------------
### Modal Static Method Call Examples
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/modal/index.md
Demonstrates the basic usage of static methods like `confirm`, `success`, `error`, `info`, and `warning` available on the `Modal` object.
```javascript
Modal.confirm(config)
Modal.success(config)
Modal.error(config)
Modal.info(config)
Modal.warning(config)
```
--------------------------------
### React Input Component Demonstrations
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/input/demos/mixin.md
This React component `InputDemo` showcases various configurations and usages of `Input` and `Mixin` components from the `cloud-react` library. It includes examples of basic input fields, merged inputs, separated inputs using `Mixin.InputInput`, range inputs with `Mixin.RangeInput`, and a select-input combination with `Mixin.SelectInput`. Users can dynamically control the disabled state, size, and border radius of the inputs using checkboxes and radio buttons.
```jsx
import React, { createRef, useState } from 'react';
import { Mixin, Icon, Input, Radio, Checkbox } from 'cloud-react';
import './styles/basic.less'
export default function InputDemo() {
const [disabled, setDisabled] = useState(false);
const [size, setSize ] = useState('default');
const [borderRadiusSize, setBorderRadiusSize] = useState('default');
return (
{
setDisabled(checked)
}}>禁用
largedefaultsmall
圆角:default圆角:medium圆角:large
两个合并输入框
两个分离输入框
{
console.log(evt);
},
}}
/>
分离区间
合并区间
下拉框+输入框
{
console.log(value);
},
}}
```
--------------------------------
### React Popover Component Examples
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/popover/demos/basic.md
This comprehensive example demonstrates various configurations and features of the `cloud-react` Popover component. It shows how to control the trigger type (click/hover), display different content types (plain text, input fields), include confirmation/cancel buttons, add icons, set titles, and handle user interactions like button clicks and form submissions within the popover. It also includes an example of a validation message using `Message.error`.
```jsx
import React, { useState, useEffect } from 'react';
import { Button, Popover, Message, Checkbox, Input } from 'cloud-react';
export default function PopoverDemo() {
const [isClick, setIsClick] = useState(true);
const [trigger, setTrigger] = useState('hover');
useEffect(() => {
setTrigger(isClick ? 'click' : 'hover');
}, [isClick]);
const split =
return (
);
}
```
--------------------------------
### Basic Usage of Cloud-React Tips Component
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/tips/demos/basic-tips.md
This React component demonstrates the fundamental usage of the `Tips` component from the `cloud-react` library. It showcases various message types (default, warning, major, success), the display of icons, and how to apply custom styles like `maxWidth` to the tips. It also illustrates rendering React nodes as message content, including emphasized text.
```jsx
/**
* title: 基础用法
* desc:
*/
import React from 'react';
import { Tips } from 'cloud-react';
import './styles/basic-tips.less';
class TipsDemo extends React.Component {
render() {
const tipsWidth = { maxWidth: '300px' };
const msgReactNode = (
重要长显显示信息强调文字变色
);
return (
);
}
}
export default TipsDemo;
```
--------------------------------
### CTable Row Disabling Example
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/c-table/demos/disabled0.md
This React JSX example illustrates how to use the `CTable` component from `cloud-react` to display tabular data. It specifically demonstrates how to mark certain rows as disabled by including `disabled: true` in their data objects. The example also covers defining columns, handling asynchronous data fetching, and integrating the table within a `Modal` component.
```jsx
/**
* title: 表格禁用行
* desc: 表格禁用行(设置 disabled: true 的形式)
*/
import React from 'react';
import { CTable, Modal, Button } from 'cloud-react';
const data = [
{ id: '121410327', name: '手机号优先继续发送1', createTime: '2021/12/14 10:19:02', creator: 'liyuan.meng', disabled: true },
{ id: '121410328', name: 'ouid疲劳度3', createTime: '2021/12/13 15:47:33 ', creator: 'jiaojiao.diao' },
{ id: '121410329', name: '继续发送手机1', createTime: '2021/12/13 15:36:42', creator: 'nan.run' },
{ id: '121408294', name: '继续发送手机2', createTime: '2021/12/13 11:14:40', creator: 'xiaotong.fan' },
{ id: '121407191', name: '继续发送手机3', createTime: '2021/12/13 11:03:05', creator: 'zhenxiao.guo' },
{ id: '121407192', name: '继续发送手机4', createTime: '2021/12/13 11:03:07', creator: 'han.wu' },
{ id: '121407193', name: '继续发送手机5', createTime: '2021/12/13 11:03:34', creator: 'yue.ren' },
{ id: '121407194', name: '继续发送手机6', createTime: '2021/12/13 11:03:05', creator: 'wanjuan.dong', disabled: true },
{ id: '121407195', name: '继续发送手机7', createTime: '2021/12/13 11:03:55', creator: 'ying.yan' },
{ id: '121407196', name: '继续发送手机8', createTime: '2021/12/13 11:03:23', creator: 'xian.yong' }
];
const columns = [
{ title: '活动ID', dataIndex: 'id', align: 'left' },
{ title: '活动名称', dataIndex: 'name', align: 'left' },
{
title: '创建时间', dataIndex: 'createTime', render: val => {
return
}
},
{ title: '创建人', dataIndex: 'creator', align: 'left' }
];
function CTableDemo(props) {
return (
{
return new Promise(resolve => {
setTimeout(() => {
resolve({
totals: data.length,
data: JSON.parse(JSON.stringify(data.slice(params.pageSize * (params.pageNum - 1), params.pageSize * params.pageNum)))
});
}, 500)
})
}}
/>
)
}
function CTableModal(props) {
return (
);
}
export default function Demo() {
return (
);
}
```
--------------------------------
### React Layout Component with Left and Right Siders
Source: https://github.com/shuyunff2e/cloud-react/blob/master/src/components/layout/demos/sider.md
This React component demonstrates how to use the `Layout` component from `cloud-react` to create page structures with a sidebar. It includes two examples: one with the `Sider` positioned on the left of the `Content` area, and another with the `Sider` on the right. It imports `Layout` from `cloud-react` and uses local styles from `sider.less`.
```jsx
/**
* title: 侧边栏
* desc: 侧边栏包含在中间
*/
import React, { Component } from 'react';
import { Layout } from 'cloud-react';
import './styles/sider.less'
const { Header, Sider, Content, Footer } = Layout;
class LayoutDemo extends Component {
render() {
return (