antd#Anchor JavaScript Examples
The following examples show how to use
antd#Anchor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From gobench with Apache License 2.0 | 6 votes |
render() {
return (
<div>
<h5 className="mb-3">
<strong>Basic</strong>
</h5>
<Anchor>
<Link title="Basic demo" />
<Link title="Static demo" />
<Link title="Basic demo with Target" />
<Link title="API">
<Link title="Anchor Props" />
<Link title="Link Props" />
</Link>
</Anchor>
</div>
)
}
Example #2
Source File: header.js From portfolyo-mern with MIT License | 5 votes |
function AppHeader() {
const [visible, setVisible] = useState(false);
const showDrawer = () => {
setVisible(true);
};
const onClose = () => {
setVisible(false);
};
return (
<div className="container-fluid">
<div className="header">
<div className="logo">
<b>Portfolyo</b>
</div>
<div className="mobileHidden">
<Anchor targetOffset="65">
<Link href="#hero" title="Home" />
<Link href="#about" title="About" />
<Link href="#creator" title="Creator" />
<Link href="#feature" title="Features" />
<Link href="#works" title="How it works" />
<Link href="#faq" title="FAQ" />
<Link href="#contact" title="Contact" />
</Anchor>
</div>
<div className="mobileVisible">
<Button type="primary" onClick={showDrawer}>
<i className="fas fa-bars"></i>
</Button>
<Drawer
placement="right"
closable={false}
onClose={onClose}
visible={visible}
>
<Anchor targetOffset="65">
<Link href="#hero" title="Home" />
<Link href="#about" title="About" />
<Link href="#feature" title="Features" />
<Link href="#creator" title="Creator" />
<Link href="#works" title="How it works" />
<Link href="#faq" title="FAQ" />
<Link href="#contact" title="Contact" />
</Anchor>
</Drawer>
</div>
</div>
</div>
);
}
Example #3
Source File: header.js From portfolyo-mern with MIT License | 5 votes |
{ Link } = Anchor
Example #4
Source File: index.js From gobench with Apache License 2.0 | 5 votes |
{ Link } = Anchor
Example #5
Source File: index.js From discern with BSD 3-Clause "New" or "Revised" License | 5 votes |
render() {
const cardContent = '使用Icon标签声明组件,指定图标对应的 type 属性。'
const cardContent2 = `我们为每个图标赋予了语义化的命名,命名规则如下:
<ul class="card-ul">
<li>实心和描线图标保持同名,用 -o 来区分,比如 question-circle(实心) 和 question-circle-o(描线);</li>
<li>命名顺序:[图标名]-[形状?]-[描线?]-[方向?]。</li>
</ul>`
return (
<div>
<CustomBreadcrumb arr={['基本','图标']}/>
<TypingCard title='如何使用' source={cardContent} id='howUse'/>
<TypingCard title='图标的命名规范' id='standard' source={cardContent2} height={206}/>
{
icons.map(item => {
return (
<Card title={item.title} bordered={false} className='card-item' key={item.title} id={item.anchor}>
{
item.list.map(icon => {
return (
<Card.Grid style={styles.gridItem} key={icon}>
<Icon type={icon} style={styles.icon}/><span>{icon}</span>
</Card.Grid>
)
})
}
</Card>
)
})
}
<BackTop visibilityHeight={200} style={{right: 50}}/>
<Affix style={styles.affixBox}>
<Anchor offsetTop={50} affix={false}>
<Anchor.Link href='#howUse' title='如何使用'/>
<Anchor.Link href='#standard' title='图标的命名规范'/>
<Anchor.Link href='#direction' title='方向性图标'/>
<Anchor.Link href='#suggestion' title='提示建议性图标'/>
<Anchor.Link href='#logo' title='网站通用图标'/>
<Anchor.Link href='#other' title='品牌和标识'/>
</Anchor>
</Affix>
</div>
)
}
Example #6
Source File: dark.jsx From virtuoso-design-system with MIT License | 5 votes |
{ Link } = Anchor
Example #7
Source File: index.js From discern with BSD 3-Clause "New" or "Revised" License | 4 votes |
render() {
const {size, bordered, loading, data2, loadingMore} = this.state
const loadMore = (
<div style={styles.loadMore}>
{/*不知道为什么这种写法有问题,会报错*/}
{/*{loadingMore ? <Spin/> : <Button onClick={() => this.getData2()}>加载更多</Button>}*/}
<Spin style={loadingMore?{}:{display:'none'}}/>
<Button style={!loadingMore?{}:{display:'none'}} onClick={() => this.getData2()}>加载更多</Button>
</div>
)
return (
<div>
<CustomBreadcrumb arr={['显示', '列表']}/>
<TypingCard id='howUse' source='最基础的列表展示,可承载文字、列表、图片、段落,常用于后台数据展示页面。'/>
<Card bordered={false} title='基本用法' style={{marginBottom: 10}} id='basicUsage'>
<Radio.Group value={size}
onChange={e => this.setState({size: e.target.value})}
style={{marginBottom: '1em'}}>
<Radio.Button value='large'>Large</Radio.Button>
<Radio.Button value='default'>Default</Radio.Button>
<Radio.Button value='small'>Small</Radio.Button>
</Radio.Group>   
是否有边框 <Switch defaultChecked
onChange={checked => this.setState({bordered: checked})}/>
<List dataSource={data}
bordered={bordered}
size={size}
style={bordered ? styles.haveBorder : styles.noBorder}
renderItem={item => (<List.Item>{item}</List.Item>)}/>
</Card>
<Card bordered={false} title='加载更多' style={{marginBottom: 10}} id='remoteLoading'>
<List loading={loading}
dataSource={data2}
loadMore={loadMore}
style={styles.listStyle}
renderItem={item => (
<List.Item actions={[<a>edit</a>, <a>more</a>]}>
<List.Item.Meta
avatar={<Avatar
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"/>}
title={<a>{item.name.last}</a>}
description="Ant Design, a design language for background applications, is refined by Ant UED Team"
/>
</List.Item>
)}
/>
</Card>
<Card bordered={false} title='竖排列表样式' style={{marginBottom: 15}} id='verticalStyle'>
<List dataSource={data3}
itemLayout='vertical'
pagination={{pageSize: 3}}
style={styles.listStyle}
renderItem={item=>{
return (
<List.Item
actions={[<IconText type="star-o" text="156" />, <IconText type="like-o" text="156" />, <IconText type="message" text="2" />]}
extra={<img width={272} alt="logo" src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png" />}>
<List.Item.Meta
avatar={<Avatar src={item.avatar} />}
title={<a>{item.title}</a>}
description={item.description}
/>
{item.content}
</List.Item>
)
}}
/>
</Card>
<BackTop visibilityHeight={200} style={{right: 50}}/>
<Affix style={styles.affixBox}>
<Anchor offsetTop={50} affix={false}>
<Anchor.Link href='#howUse' title='何时使用'/>
<Anchor.Link href='#basicUsage' title='基本用法'/>
<Anchor.Link href='#remoteLoading' title='加载更多'/>
<Anchor.Link href='#verticalStyle' title='竖排列表样式'/>
</Anchor>
</Affix>
</div>
)
}
Example #8
Source File: index.js From discern with BSD 3-Clause "New" or "Revised" License | 4 votes |
render() {
const rowSelection = {
selections: true
}
let {sortedInfo, filteredInfo} = this.state
sortedInfo = sortedInfo || {}
filteredInfo = filteredInfo || {}
const columns3 = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
filters: [
{text: 'Joe', value: 'Joe'},
{text: 'Jim', value: 'Jim'},
],
filteredValue: filteredInfo.name || null,
onFilter: (value, record) => record.name.includes(value),
sorter: (a, b) => a.name.length - b.name.length,
sortOrder: sortedInfo.columnKey === 'name' && sortedInfo.order,
}, {
title: 'Age',
dataIndex: 'age',
key: 'age',
sorter: (a, b) => a.age - b.age,
sortOrder: sortedInfo.columnKey === 'age' && sortedInfo.order,
}, {
title: 'Address',
dataIndex: 'address',
key: 'address',
filters: [
{text: 'London', value: 'London'},
{text: 'New York', value: 'New York'},
],
filteredValue: filteredInfo.address || null,
onFilter: (value, record) => record.address.includes(value),
sorter: (a, b) => a.address.length - b.address.length,
sortOrder: sortedInfo.columnKey === 'address' && sortedInfo.order,
}]
const components = {
body: {
row: EditableFormRow,
cell: EditableCell,
},
};
const columns8 = this.columns8.map((col) => {
if (!col.editable) {
return col;
}
return {
...col,
onCell: record => ({
record,
inputType: col.dataIndex === 'age' ? 'number' : 'text',
dataIndex: col.dataIndex,
title: col.title,
editing: this.isEditing(record),
}),
};
});
const cardContent = `<ul class="card-ul">
<li>当有大量结构化的数据需要展现时</li>
<li>标当需要对数据进行排序、搜索、分页、自定义操作等复杂行为时</li>
</ul>`
return (
<div>
<CustomBreadcrumb arr={['显示', '表格']}/>
<TypingCard id='howUse' source={cardContent} height={178}/>
<Card bordered={false} title='基本用法' style={{marginBottom: 10}} id='basicUsage'>
<Table dataSource={data} columns={columns} style={styles.tableStyle}/>
</Card>
<Card bordered={false} title='可选择' style={{marginBottom: 10, minHeight: 762}} id='select'>
<Table rowSelection={rowSelection} dataSource={data2} columns={columns2} style={styles.tableStyle}/>
</Card>
<Card bordered={false} title='排序和筛选' style={{marginBottom: 10, minHeight: 400}} id='filterOrSort'>
<p>
<Button onClick={() => this.setSort('age')}>年龄排序</Button> 
<Button onClick={() => this.setSort('name')}>人名排序</Button> 
<Button onClick={this.clearFilters}>清空过滤规则</Button> 
<Button onClick={this.clearAll}>重置</Button>
</p>
<Table dataSource={data3} columns={columns3} style={styles.tableStyle} onChange={this.handleChange}/>
</Card>
<Card bordered={false} title='远程加载数据' style={{marginBottom: 10, minHeight: 762}} id='remoteLoading'>
<Table rowKey={record => record.login.uuid}
loading={this.state.loading}
dataSource={this.state.data4}
pagination={this.state.pagination}
onChange={this.handleTableChange}
columns={columns4} style={styles.tableStyle}/>u
</Card>
<Card bordered={false} title='可展开' style={{marginBottom: 10, minHeight: 440}} id='unfold'>
<Table dataSource={data5} columns={columns5} style={styles.tableStyle}
expandedRowRender={record => <p style={{margin: 0}}>{record.description}</p>}/>
</Card>
<Card bordered={false} title='固定头和列' style={{marginBottom: 10, minHeight: 440}} id='fixed'>
<Table dataSource={data6} columns={columns6} style={styles.tableStyle}
scroll={{x: 1500, y: 500}}/>
</Card>
<Card bordered={false} title='可编辑的表格' style={{marginBottom: 10, minHeight: 440}} id='editTable'>
<p>
<Button onClick={this.handleAdd}>添加行</Button>
</p>
<Table bordered dataSource={this.state.data7} columns={this.columns7} style={styles.tableStyle}/>
<Table style={styles.tableStyle} components={components} bordered dataSource={this.state.data8}
columns={columns8}/>
</Card>
<BackTop visibilityHeight={200} style={{right: 50}}/>
<Affix style={styles.affixBox}>
<Anchor offsetTop={50} affix={false}>
<Anchor.Link href='#howUse' title='何时使用'/>
<Anchor.Link href='#basicUsage' title='基本用法'/>
<Anchor.Link href='#select' title='可选择'/>
<Anchor.Link href='#filterOrSort' title='排序和筛选'/>
<Anchor.Link href='#remoteLoading' title='远程加载数据'/>
<Anchor.Link href='#unfold' title='可展开'/>
<Anchor.Link href='#fixed' title='固定头和列'/>
<Anchor.Link href='#editTable' title='可编辑的表格'/>
</Anchor>
</Affix>
</div>
)
}
Example #9
Source File: dark.jsx From virtuoso-design-system with MIT License | 4 votes |
render() {
const { disabled, selectedKeys, targetKeys, showSearch } = this.state;
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
filters: [
{ text: 'Joe', value: 'Joe' },
{ text: 'Jim', value: 'Jim' },
],
filteredValue: null,
onFilter: (value, record) => record.name.includes(value),
sorter: (a, b) => a.name.length - b.name.length,
sortOrder: true,
ellipsis: true,
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
sorter: false,
sortOrder: true,
ellipsis: true,
},
{
title: 'Address',
dataIndex: 'address',
key: 'address',
filters: [
{ text: 'London', value: 'London' },
{ text: 'New York', value: 'New York' },
],
filteredValue: null,
onFilter: (value, record) => record.address.includes(value),
sorter: false,
sortOrder: true,
ellipsis: true,
},
];
return (
<>
<Button type="primary" onClick={this.showModal}>
Open Modal
</Button>
<Modal
title="Basic Modal"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<Switch
unCheckedChildren="disabled"
checkedChildren="disabled"
checked={disabled}
onChange={this.handleDisable}
style={{ marginBottom: 16 }}
/>
<Card title="Card Title">
<Card.Grid>Content</Card.Grid>
<Card.Grid hoverable={false}>Content</Card.Grid>
<Card.Grid>Content</Card.Grid>
<Card.Grid>Content</Card.Grid>
<Card.Grid>Content</Card.Grid>
<Card.Grid>Content</Card.Grid>
<Card.Grid>Content</Card.Grid>
</Card>
<Collapse>
<Panel header="This is panel header 1" key="1">
<Collapse defaultActiveKey="1">
<Panel header="This is panel nest panel" key="1">
<p>{text}</p>
</Panel>
</Collapse>
</Panel>
<Panel header="This is panel header 2" key="2">
<p>{text}</p>
</Panel>
<Panel header="This is panel header 3" key="3">
<p>{text}</p>
</Panel>
</Collapse>
<Transfer
dataSource={mockData}
titles={['Source', 'Target']}
targetKeys={targetKeys}
selectedKeys={selectedKeys}
onChange={this.handleTransferChange}
onSelectChange={this.handleTransferSelectChange}
render={item => item.title}
disabled={disabled}
/>
<TableTransfer
dataSource={mockData}
targetKeys={targetKeys}
disabled={disabled}
showSearch={showSearch}
onChange={this.handleTableTransferChange}
filterOption={(inputValue, item) =>
item.title.indexOf(inputValue) !== -1 || item.tag.indexOf(inputValue) !== -1
}
leftColumns={[
{
dataIndex: 'title',
title: 'Name',
},
{
dataIndex: 'description',
title: 'Description',
},
]}
rightColumns={[
{
dataIndex: 'title',
title: 'Name',
},
]}
/>
<Switch
unCheckedChildren="disabled"
checkedChildren="disabled"
checked={disabled}
onChange={this.triggerDisable}
style={{ marginTop: 16 }}
/>
<Switch
unCheckedChildren="showSearch"
checkedChildren="showSearch"
checked={showSearch}
onChange={this.triggerShowSearch}
style={{ marginTop: 16 }}
/>
<Anchor>
<Link href="#components-anchor-demo-basic" title="Basic demo" />
<Link href="#components-anchor-demo-static" title="Static demo" />
<Link
href="#components-anchor-demo-basic"
title="Basic demo with Target"
target="_blank"
/>
<Link href="#API" title="API">
<Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" />
</Link>
</Anchor>
<Tabs type="card">
<TabPane tab="Tab 1" key="1">
Content of Tab Pane 1
</TabPane>
<TabPane tab="Tab 2" key="2">
Content of Tab Pane 2
</TabPane>
<TabPane tab="Tab 3" key="3">
Content of Tab Pane 3
</TabPane>
</Tabs>
<Timeline>
<Timeline.Item>Create a services site 2015-09-01</Timeline.Item>
<Timeline.Item>Solve initial network problems 2015-09-01</Timeline.Item>
<Timeline.Item dot={<ClockCircleOutlined style={{ fontSize: '16px' }} />} color="red">
Technical testing 2015-09-01
</Timeline.Item>
<Timeline.Item>Network problems being solved 2015-09-01</Timeline.Item>
</Timeline>
<Calendar />
<Tree showLine switcherIcon={<DownOutlined />} defaultExpandedKeys={['0-0-0']}>
<TreeNode title="parent 1" key="0-0">
<TreeNode title="parent 1-0" key="0-0-0">
<TreeNode title="leaf" key="0-0-0-0" />
<TreeNode title="leaf" key="0-0-0-1" />
<TreeNode title="leaf" key="0-0-0-2" />
</TreeNode>
<TreeNode title="parent 1-1" key="0-0-1">
<TreeNode title="leaf" key="0-0-1-0" />
</TreeNode>
<TreeNode title="parent 1-2" key="0-0-2">
<TreeNode title="leaf" key="0-0-2-0" />
<TreeNode title="leaf" key="0-0-2-1" />
</TreeNode>
</TreeNode>
</Tree>
<Table columns={columns} dataSource={data} footer={() => 'Footer'} />
<Table
columns={columnsTable}
dataSource={dataTable}
pagination={false}
id="table-demo-summary"
bordered
summary={pageData => {
let totalBorrow = 0;
let totalRepayment = 0;
pageData.forEach(({ borrow, repayment }) => {
totalBorrow += borrow;
totalRepayment += repayment;
});
return (
<>
<tr>
<th>Total</th>
<td>
<Text type="danger">{totalBorrow}</Text>
</td>
<td>
<Text>{totalRepayment}</Text>
</td>
</tr>
<tr>
<th>Balance</th>
<td colSpan={2}>
<Text type="danger">{totalBorrow - totalRepayment}</Text>
</td>
</tr>
</>
);
}}
/>
<br />
<Table columns={columnsNest} expandable={{ expandedRowRender }} dataSource={dataNest} />
<Table columns={columnsFixed} dataSource={dataFixed} scroll={{ x: 1300, y: 100 }} />
<Card
hoverable
style={{ width: 240 }}
cover={
<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" />
}
>
<Meta title="Europe Street beat" description="www.instagram.com" />
</Card>
<Slider defaultValue={30} />
<DatePicker defaultValue={moment('2015/01/01', 'YYYY/MM/DD')} format="YYYY/MM/DD" />
<Badge count={5}>
<a href="#" className="head-example" />
</Badge>
</Modal>
</>
);
}