import * as React from 'react' import styled from '@emotion/styled' import { Gridley, Cell, Columns, Column, Layout, useCurrentLayout, GridleyProps, } from '../src/index' import { Person, makeData } from './data' // an example of how to add styles to the Grid // styles listed in this manner will override gridley provided styles const Grid = styled(Gridley)({ borderBottom: '1px solid lightGrey', }) // A custom component that renders the first name along with a custom data attribute const FirstName: React.FC<{ role?: React.AriaRole; id?: string; value?: string }> = ({ id, role, value: name, }) => ( {name} ) const CaptionDiv = styled.div({ background: 'white', height: '30px', alignItems: 'center', display: 'flex', justifyContent: 'space-between', position: 'sticky', top: 0, }) // caption uses the "useCurrentLayout" hook to obtain the current layout id const Caption: React.FC<{ onUpdate(): void }> = ({ onUpdate }) => { const layout = useCurrentLayout() return ( Gridley Demo ({layout?.id}) ) } interface DemoProps extends Omit, 'data'> { data?: Person[] } const Demo: React.FC = ({ data: initialData, props }) => { const [data, setData] = React.useState(initialData || makeData()) const [showJob, setShowJob] = React.useState(true) const onUpdate = React.useCallback(() => { setShowJob(false) setData(makeData()) }, [setShowJob, setData]) return ( ({ 'data-row-id': r.id })} defaultLayout="mobile" caption={} {...props} > ID} body={ {p.id}} />} /> First Name} body={} /> Phone} body={} /> Last Name} body={ id} />} /> Job} body={} /> Address} body={} /> {showJob && } ) } export default Demo