style(ui): add generic divider lines before nested object sections
This commit is contained in:
parent
c1dc542975
commit
a05c3c71b1
|
|
@ -36,7 +36,7 @@ export const DivergentChannel = ({ data }: { data: Record<string, unknown> }) =>
|
||||||
export const LuoChannel = ({ data }: { data: Record<string, unknown> }) => (
|
export const LuoChannel = ({ data }: { data: Record<string, unknown> }) => (
|
||||||
<SectionCard title="Luo-Connecting Channel">
|
<SectionCard title="Luo-Connecting Channel">
|
||||||
<BulletList items={asStringArray(data.luo_connecting_channel)} />
|
<BulletList items={asStringArray(data.luo_connecting_channel)} />
|
||||||
<ObjectSections value={asRecord(data.luo_connecting_vessel)} />
|
<ObjectSections value={asRecord(data.luo_connecting_vessel)} withTopDivider />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,10 @@ export function MeridianDetailRenderer({
|
||||||
<>
|
<>
|
||||||
<BulletList items={asStringArray(value)} />
|
<BulletList items={asStringArray(value)} />
|
||||||
{isPresent(data.luo_connecting_vessel) ? (
|
{isPresent(data.luo_connecting_vessel) ? (
|
||||||
<ObjectSections value={asRecord(data.luo_connecting_vessel)} />
|
<ObjectSections
|
||||||
|
value={asRecord(data.luo_connecting_vessel)}
|
||||||
|
withTopDivider
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -592,6 +592,9 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
subSectionSpacing: {
|
subSectionSpacing: {
|
||||||
marginTop: verticalScale(12),
|
marginTop: verticalScale(12),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
borderTopWidth: StyleSheet.hairlineWidth,
|
||||||
|
borderTopColor: "#E8ECEF",
|
||||||
},
|
},
|
||||||
subSectionTitle: {
|
subSectionTitle: {
|
||||||
fontSize: moderateScale(13),
|
fontSize: moderateScale(13),
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,13 @@ export function ContentValue({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View key={key} style={styles.objectRow}>
|
<View
|
||||||
|
key={key}
|
||||||
|
style={[
|
||||||
|
styles.objectRow,
|
||||||
|
index > 0 && styles.divider,
|
||||||
|
]}
|
||||||
|
>
|
||||||
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
||||||
{renderChild()}
|
{renderChild()}
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -177,6 +183,11 @@ const styles = StyleSheet.create({
|
||||||
objectRow: {
|
objectRow: {
|
||||||
gap: 4,
|
gap: 4,
|
||||||
},
|
},
|
||||||
|
divider: {
|
||||||
|
paddingTop: 12,
|
||||||
|
borderTopWidth: StyleSheet.hairlineWidth,
|
||||||
|
borderTopColor: "#E8ECEF",
|
||||||
|
},
|
||||||
objectLabel: {
|
objectLabel: {
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
lineHeight: 17,
|
lineHeight: 17,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,13 @@ import { ContentValue } from "./ContentValue";
|
||||||
* content references. ContentValue recursively handles arrays, objects and
|
* content references. ContentValue recursively handles arrays, objects and
|
||||||
* hydrated content/template references.
|
* hydrated content/template references.
|
||||||
*/
|
*/
|
||||||
export function ObjectSections({ value }: { value: Record<string, unknown> }) {
|
export function ObjectSections({
|
||||||
|
value,
|
||||||
|
withTopDivider = false,
|
||||||
|
}: {
|
||||||
|
value: Record<string, unknown>;
|
||||||
|
withTopDivider?: boolean;
|
||||||
|
}) {
|
||||||
const entries = Object.entries(value).filter(([, child]) =>
|
const entries = Object.entries(value).filter(([, child]) =>
|
||||||
isPresent(child),
|
isPresent(child),
|
||||||
);
|
);
|
||||||
|
|
@ -18,8 +24,14 @@ export function ObjectSections({ value }: { value: Record<string, unknown> }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.root}>
|
<View style={styles.root}>
|
||||||
{entries.map(([key, child]) => (
|
{entries.map(([key, child], index) => (
|
||||||
<View key={key} style={styles.section}>
|
<View
|
||||||
|
key={key}
|
||||||
|
style={[
|
||||||
|
styles.section,
|
||||||
|
(index > 0 || withTopDivider) && styles.divider,
|
||||||
|
]}
|
||||||
|
>
|
||||||
<Text style={styles.label}>{humanizeKey(key)}</Text>
|
<Text style={styles.label}>{humanizeKey(key)}</Text>
|
||||||
<ContentValue value={child} />
|
<ContentValue value={child} />
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -40,6 +52,11 @@ function isPresent(value: unknown): boolean {
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
root: { gap: 16 },
|
root: { gap: 16 },
|
||||||
section: { gap: 7 },
|
section: { gap: 7 },
|
||||||
|
divider: {
|
||||||
|
paddingTop: 12,
|
||||||
|
borderTopWidth: StyleSheet.hairlineWidth,
|
||||||
|
borderTopColor: "#E8ECEF",
|
||||||
|
},
|
||||||
label: {
|
label: {
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue