Skip to content

Commit

Permalink
✨ feat: Add align to list view
Browse files Browse the repository at this point in the history
  • Loading branch information
caoccao committed Aug 27, 2024
1 parent 6e0fabc commit a42c914
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/lib/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export function transformDuration(value: string | undefined | null): string {
return "";
}

export function transformFPS(value: string | undefined | null): string {
if (value) {
return trimFractionZeros(value);
}
return "";
}

export function transformResolution(
_value: any,
rowData: Record<string, string>,
Expand Down
42 changes: 37 additions & 5 deletions src/routes/list.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
transformBitRate,
transformDefault,
transformDuration,
transformFPS,
transformResolution,
transformSamplingRate,
transformSize,
Expand All @@ -60,17 +61,18 @@
}
class PropertyDefinition {
align: "left" | "right" | "center" | "justify";
format: (
value: any,
rowData: Record<string, string>,
rowIndex: number
) => string;
headerForCardView: string | null;
headerForListView: string | null;
name: string;
virtual: boolean;
inCardView: boolean;
inListView: boolean;
name: string;
virtual: boolean;
constructor(
name: string,
Expand All @@ -82,6 +84,7 @@
headerForCardView: string | null = null,
headerForListView: string | null = null
) {
this.align = "left";
this.format = format;
this.headerForCardView = headerForCardView;
this.headerForListView = headerForListView;
Expand All @@ -99,6 +102,21 @@
return this.headerForListView ?? this.name;
}
setAlignCenter(): PropertyDefinition {
this.align = "center";
return this;
}
setAlignLeft(): PropertyDefinition {
this.align = "left";
return this;
}
setAlignRight(): PropertyDefinition {
this.align = "right";
return this;
}
setHeaderForCardView(header: string | null): PropertyDefinition {
this.headerForCardView = header;
return this;
Expand Down Expand Up @@ -128,7 +146,7 @@
return {
name: this.name,
header: this.getHeaderForCardView(),
align: "left",
align: this.align,
format: this.format,
};
}
Expand All @@ -139,7 +157,7 @@
return {
name: `${stream}:${this.name}`,
header: this.getHeaderForListView(),
align: "left",
align: this.align,
format: this.format,
};
}
Expand All @@ -165,12 +183,15 @@
.setInCardView()
.setInListView(),
new PropertyDefinition("FileSize", transformSize, "Size", "File Size")
.setAlignRight()
.setInCardView()
.setInListView(),
new PropertyDefinition("Duration", transformDuration)
.setAlignRight()
.setInCardView()
.setInListView(),
new PropertyDefinition("Time", transformTime)
.setAlignRight()
.setVirtual()
.setInCardView()
.setInListView(),
Expand Down Expand Up @@ -216,11 +237,13 @@
new PropertyDefinition("Default").setHeaderForCardView("D"),
new PropertyDefinition("Forced").setHeaderForCardView("F"),
new PropertyDefinition("BitDepth")
.setAlignRight()
.setHeaderForCardView("Depth")
.setHeaderForListView("Video Bit Depth")
.setInCardView()
.setInListView(),
new PropertyDefinition("FrameRate")
new PropertyDefinition("FrameRate", transformFPS)
.setAlignRight()
.setHeaderForCardView("FPS")
.setHeaderForListView("FPS")
.setInCardView()
Expand All @@ -231,9 +254,11 @@
"Bit Rate",
"Video Bit Rate"
)
.setAlignRight()
.setInCardView()
.setInListView(),
new PropertyDefinition("StreamSize", transformSize, "Size", "Video Size")
.setAlignRight()
.setInCardView()
.setInListView(),
new PropertyDefinition("Width"),
Expand All @@ -256,11 +281,13 @@
.setInCardView()
.setInListView(),
new PropertyDefinition("Channel(s)")
.setAlignRight()
.setHeaderForCardView("CH")
.setHeaderForListView("CH")
.setInCardView()
.setInListView(),
new PropertyDefinition("BitDepth")
.setAlignRight()
.setHeaderForCardView("Depth")
.setHeaderForListView("Audio Bit Depth")
.setInCardView()
Expand All @@ -271,6 +298,7 @@
"Sampling",
"Audio Sampling Rate"
)
.setAlignRight()
.setInCardView()
.setInListView(),
new PropertyDefinition("Default").setHeaderForCardView("D").setInCardView(),
Expand All @@ -286,9 +314,11 @@
"Bit Rate",
"Audio Bit Rate"
)
.setAlignRight()
.setInCardView()
.setInListView(),
new PropertyDefinition("StreamSize", transformSize, "Size", "Audio Size")
.setAlignRight()
.setInCardView()
.setInListView(),
];
Expand All @@ -315,9 +345,11 @@
"Bit Rate",
"Text Bit Rate"
)
.setAlignRight()
.setInCardView()
.setInListView(),
new PropertyDefinition("StreamSize", transformSize, "Size", "Text Size")
.setAlignRight()
.setInCardView()
.setInListView(),
];
Expand Down

0 comments on commit a42c914

Please sign in to comment.