|
| 1 | +--- |
| 2 | +title: React Widgets |
| 3 | +name: Widgets |
| 4 | +description: React alert component gives contextual feedback information for common user operations. The alert component is delivered with a bunch of usable and adjustable alert messages. |
| 5 | +menu: Components |
| 6 | +route: /components/widgets |
| 7 | +--- |
| 8 | + |
| 9 | +import { Playground, Props } from 'docz' |
| 10 | +import CIcon from '@coreui/icons-react' |
| 11 | +import { cilArrowTop, cilChartPie, cilOptions } from '@coreui/icons' |
| 12 | +import { CChartLine } from '@coreui/react-chartjs' |
| 13 | + |
| 14 | +import { |
| 15 | + CCol, |
| 16 | + CDropdown, |
| 17 | + CDropdownItem, |
| 18 | + CDropdownMenu, |
| 19 | + CDropdownToggle, |
| 20 | + CRow, |
| 21 | + CWidgetA, |
| 22 | + CWidgetB, |
| 23 | + CWidgetC, |
| 24 | +} from '../../../src/index.ts' |
| 25 | + |
| 26 | + |
| 27 | +## Examples |
| 28 | + |
| 29 | +React Alert is prepared for any length of text, as well as an optional close button. For a styling, use one of the **required** contextual `color` props (e.g., `primary`). For inline dismissal, use the [dismissing prop](#dismissing). |
| 30 | + |
| 31 | +## CWidgetA |
| 32 | + |
| 33 | +<Playground> |
| 34 | + <CRow> |
| 35 | + <CCol sm={6}> |
| 36 | + <CWidgetA |
| 37 | + className="mb-4" |
| 38 | + color="primary" |
| 39 | + value={<>$9.000 <span className="fs-6 fw-normal">(40.9% <CIcon icon={cilArrowTop} />)</span></>} |
| 40 | + title="Widget title" |
| 41 | + action={ |
| 42 | + <CDropdown alignment="end"> |
| 43 | + <CDropdownToggle color="transparent" caret={false} className="p-0"> |
| 44 | + <CIcon icon={cilOptions} className="text-high-emphasis-inverse" /> |
| 45 | + </CDropdownToggle> |
| 46 | + <CDropdownMenu> |
| 47 | + <CDropdownItem>Action</CDropdownItem> |
| 48 | + <CDropdownItem>Another action</CDropdownItem> |
| 49 | + <CDropdownItem>Something else here...</CDropdownItem> |
| 50 | + <CDropdownItem disabled>Disabled action</CDropdownItem> |
| 51 | + </CDropdownMenu> |
| 52 | + </CDropdown> |
| 53 | + } |
| 54 | + chart={ |
| 55 | + <CChartLine |
| 56 | + className="mt-3 mx-3" |
| 57 | + style={{ height: '70px' }} |
| 58 | + data={{ |
| 59 | + labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], |
| 60 | + datasets: [ |
| 61 | + { |
| 62 | + label: 'My First dataset', |
| 63 | + backgroundColor: 'transparent', |
| 64 | + borderColor: 'rgba(255,255,255,.55)', |
| 65 | + pointBackgroundColor: '#321fdb', |
| 66 | + data: [65, 59, 84, 84, 51, 55, 40], |
| 67 | + }, |
| 68 | + ], |
| 69 | + }} |
| 70 | + options={{ |
| 71 | + plugins: { |
| 72 | + legend: { |
| 73 | + display: false, |
| 74 | + }, |
| 75 | + }, |
| 76 | + maintainAspectRatio: false, |
| 77 | + scales: { |
| 78 | + x: { |
| 79 | + grid: { |
| 80 | + display: false, |
| 81 | + drawBorder: false, |
| 82 | + }, |
| 83 | + ticks: { |
| 84 | + display: false, |
| 85 | + }, |
| 86 | + }, |
| 87 | + y: { |
| 88 | + min: 30, |
| 89 | + max: 89, |
| 90 | + display: false, |
| 91 | + grid: { |
| 92 | + display: false, |
| 93 | + }, |
| 94 | + ticks: { |
| 95 | + display: false, |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + elements: { |
| 100 | + line: { |
| 101 | + borderWidth: 1, |
| 102 | + tension: 0.4, |
| 103 | + }, |
| 104 | + point: { |
| 105 | + radius: 4, |
| 106 | + hitRadius: 10, |
| 107 | + hoverRadius: 4, |
| 108 | + }, |
| 109 | + }, |
| 110 | + }} |
| 111 | + /> |
| 112 | + } |
| 113 | + /> |
| 114 | + </CCol> |
| 115 | + </CRow> |
| 116 | +</Playground> |
| 117 | + |
| 118 | +## CWidgetB |
| 119 | + |
| 120 | +<Playground> |
| 121 | + <CRow> |
| 122 | + <CCol xs={6}> |
| 123 | + <CWidgetB |
| 124 | + className="mb-3" |
| 125 | + progress={{ color: 'success', value: 75 }} |
| 126 | + text="Widget helper text" |
| 127 | + title="Widget title" |
| 128 | + value="89.9%"/> |
| 129 | + </CCol> |
| 130 | + <CCol xs={6}> |
| 131 | + <CWidgetB |
| 132 | + className="mb-3" |
| 133 | + color="primary" |
| 134 | + inverse |
| 135 | + progress={{ value: 75 }} |
| 136 | + text="Widget helper text" |
| 137 | + title="Widget title" |
| 138 | + value="89.9%"/> |
| 139 | + </CCol> |
| 140 | + </CRow> |
| 141 | +</Playground> |
| 142 | + |
| 143 | +## CWidgetC |
| 144 | + |
| 145 | +<Playground> |
| 146 | + <CRow> |
| 147 | + <CCol xs={6}> |
| 148 | + <CWidgetC |
| 149 | + className="mb-3" |
| 150 | + icon={<CIcon icon={cilChartPie} height={36} />} |
| 151 | + progress={{ color: 'success', value: 75 }} |
| 152 | + text="Widget helper text" |
| 153 | + title="Widget title" |
| 154 | + value="89.9%"/> |
| 155 | + </CCol> |
| 156 | + <CCol xs={6}> |
| 157 | + <CWidgetC |
| 158 | + className="mb-3" |
| 159 | + icon={<CIcon icon={cilChartPie} height={36} />} |
| 160 | + color="primary" |
| 161 | + inverse |
| 162 | + progress={{ value: 75 }} |
| 163 | + text="Widget helper text" |
| 164 | + title="Widget title" |
| 165 | + value="89.9%"/> |
| 166 | + </CCol> |
| 167 | + </CRow> |
| 168 | +</Playground> |
| 169 | + |
| 170 | +## API |
| 171 | + |
| 172 | +### CWidgetA |
| 173 | + |
| 174 | +<Props of={CWidgetA} /> |
0 commit comments