Skip to content

Commit

Permalink
feat(platform): add aLabelAlign prop to detail-view
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejay97 committed Dec 1, 2022
1 parent f752d3f commit 9710203
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/platform/src/app/components/detail-view/DetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface AppDetailViewProps extends Omit<React.HTMLAttributes<HTMLDivEle
}[];
aCol?: number | true | Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number | true>;
aGutter?: number | [number?, number?];
aLabelAlign?: 'left' | 'center' | 'right';
aLabelWidth?: string | number;
aEmpty?: React.ReactNode;
aVertical?: boolean;
Expand All @@ -21,14 +22,15 @@ export function AppDetailView(props: AppDetailViewProps): JSX.Element | null {
aList,
aCol = { xs: 12, md: 6, lg: 4, xxl: 3 },
aGutter,
aLabelAlign = 'left',
aLabelWidth,
aEmpty = '-',
aVertical = false,

...restProps
} = props;

const [gutterX, gutterY] = isArray(aGutter) ? aGutter : [aGutter, aGutter];
const [gutterY, gutterX] = isArray(aGutter) ? aGutter : [aGutter, aGutter];
const col = (() => {
if (aCol === true) {
return 'col';
Expand Down Expand Up @@ -81,7 +83,13 @@ export function AppDetailView(props: AppDetailViewProps): JSX.Element | null {
: _isEmpty;
return (
<div key={label} className={getClassName('app-detail-view__item', col)}>
<div className="app-detail-view__item-label" style={{ width: labelWidth }}>
<div
className="app-detail-view__item-label"
style={{
width: labelWidth,
textAlign: aLabelAlign,
}}
>
{label}
</div>
<div className="app-detail-view__item-content">{isEmpty ? aEmpty : content}</div>
Expand Down
6 changes: 5 additions & 1 deletion packages/platform/src/styles/components/detail-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@include e(item) {
display: inline-flex;
gap: 8px;
gap: 8px 12px;
}

@include e(item-label) {
Expand All @@ -25,4 +25,8 @@
content: ':';
}
}

@include e(item-content) {
word-break: break-all;
}
}

0 comments on commit 9710203

Please sign in to comment.