-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05fc47c
commit dd5ddaa
Showing
18 changed files
with
349 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { FC } from 'react' | ||
|
||
import { asTitle } from '../tools' | ||
import { ClassName, useClassName } from '../hooks/className' | ||
|
||
import { DisplayComp, DisplayLookupProps, ModelData, renderEvent } from './display' | ||
|
||
export interface DetailsProps { | ||
type: 'Details' | ||
data: ModelData | ||
fields: DisplayLookupProps[] | ||
className?: ClassName | ||
} | ||
|
||
export const DetailsComp: FC<DetailsProps> = (props) => ( | ||
<dl className={useClassName(props)}> | ||
{props.fields.map((field, id) => ( | ||
<FieldDetail key={id} props={props} fieldDisplay={field} /> | ||
))} | ||
</dl> | ||
) | ||
|
||
const FieldDetail: FC<{ props: DetailsProps; fieldDisplay: DisplayLookupProps }> = ({ props, fieldDisplay }) => { | ||
const { field, title, onClick, ...rest } = fieldDisplay | ||
const value = props.data[field] | ||
const renderedOnClick = renderEvent(onClick, props.data) | ||
return ( | ||
<> | ||
<dt className={useClassName(props, { el: 'dt' })}>{title ?? asTitle(field)}</dt> | ||
<dd className={useClassName(props, { el: 'dd' })}> | ||
<DisplayComp type="Display" onClick={renderedOnClick} value={value} {...rest} /> | ||
</dd> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.