coreui-free-react-admin-template
135 строк · 5.1 Кб
1import React, { useState } from 'react'2import { CButton, CCard, CCardBody, CCardHeader, CCol, CCollapse, CRow } from '@coreui/react'3import { DocsExample } from 'src/components'4
5const Collapses = () => {6const [visible, setVisible] = useState(false)7const [visibleHorizontal, setVisibleHorizontal] = useState(false)8const [visibleA, setVisibleA] = useState(false)9const [visibleB, setVisibleB] = useState(false)10
11return (12<CRow>13<CCol xs={12}>14<CCard className="mb-4">15<CCardHeader>16<strong>React Collapse</strong>17</CCardHeader>18<CCardBody>19<p className="text-body-secondary small">You can use a link or a button component.</p>20<DocsExample href="components/collapse">21<CButton22color="primary"23href="#"24onClick={(e) => {25e.preventDefault()26setVisible(!visible)27}}28>29Link
30</CButton>31<CButton color="primary" onClick={() => setVisible(!visible)}>32Button
33</CButton>34<CCollapse visible={visible}>35<CCard className="mt-3">36<CCardBody>37Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry38richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes39anderson cred nesciunt sapiente ea proident.40</CCardBody>41</CCard>42</CCollapse>43</DocsExample>44</CCardBody>45</CCard>46</CCol>47<CCol xs={12}>48<CCard className="mb-4">49<CCardHeader>50<strong>React Collapse</strong> <small> Horizontal</small>51</CCardHeader>52<CCardBody>53<p className="text-body-secondary small">You can use a link or a button component.</p>54<DocsExample href="components/collapse#horizontal">55<CButton56className="mb-3"57color="primary"58onClick={() => setVisibleHorizontal(!visibleHorizontal)}59aria-expanded={visibleHorizontal}60aria-controls="collapseWidthExample"61>62Button
63</CButton>64<div style={{ minHeight: '120px' }}>65<CCollapse id="collapseWidthExample" horizontal visible={visibleHorizontal}>66<CCard style={{ width: '300px' }}>67<CCardBody>68This is some placeholder content for a horizontal collapse. It's hidden by69default and shown when triggered.70</CCardBody>71</CCard>72</CCollapse>73</div>74</DocsExample>75</CCardBody>76</CCard>77</CCol>78<CCol xs={12}>79<CCard className="mb-4">80<CCardHeader>81<strong>React Collapse</strong> <small> multi target</small>82</CCardHeader>83<CCardBody>84<p className="text-body-secondary small">85A <code><CButton></code> can show and hide multiple elements.86</p>87<DocsExample href="components/collapse#multiple-targets">88<CButton color="primary" onClick={() => setVisibleA(!visibleA)}>89Toggle first element
90</CButton>91<CButton color="primary" onClick={() => setVisibleB(!visibleB)}>92Toggle second element
93</CButton>94<CButton95color="primary"96onClick={() => {97setVisibleA(!visibleA)98setVisibleB(!visibleB)99}}100>101Toggle both elements
102</CButton>103<CRow>104<CCol xs={6}>105<CCollapse visible={visibleA}>106<CCard className="mt-3">107<CCardBody>108Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry109richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes110anderson cred nesciunt sapiente ea proident.111</CCardBody>112</CCard>113</CCollapse>114</CCol>115<CCol xs={6}>116<CCollapse visible={visibleB}>117<CCard className="mt-3">118<CCardBody>119Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry120richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes121anderson cred nesciunt sapiente ea proident.122</CCardBody>123</CCard>124</CCollapse>125</CCol>126</CRow>127</DocsExample>128</CCardBody>129</CCard>130</CCol>131</CRow>132)133}
134
135export default Collapses136