Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/utils/memberCard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ describe("the banner's fade", () => {
});
});

describe("the banner's height", () => {
it("keeps the short banner and leaves out the tall one", () => {
assert.deepEqual(normaliseCardStyle({ bannerSize: "short" }), { bannerSize: "short" });
assert.equal(normaliseCardStyle({ bannerSize: "tall" }), null);
assert.equal(normaliseCardStyle({ bannerSize: true }), null);
});
});

describe("the plain card as a choice", () => {
it("is kept when it is the whole style, so it isn't read as no card", () => {
assert.deepEqual(normaliseCardStyle({ plain: true }), { plain: true });
Expand Down
3 changes: 3 additions & 0 deletions src/utils/memberCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export interface CardStyle {
pLayer?: "front";
/** The card's outline in pixels. Leaves out its default (1). */
edge?: number;
/** "short" draws the banner at its low height. Absent is tall; the stored banner box doesn't change. */
bannerSize?: "short";
/** The plain card as a choice. With no style at all, apps draw one worked out from the member's name. */
plain?: true;
}
Expand Down Expand Up @@ -124,6 +126,7 @@ export function normaliseCardStyle(value: unknown): CardStyle | null {
if (raw.pLayer === "front") out.pLayer = "front";
const edge = readInt(raw.edge, 0, 6);
if (edge !== undefined && edge !== 1) out.edge = edge;
if (raw.bannerSize === "short") out.bannerSize = "short";

// Only when nothing else is set: with a colour or a pattern the card isn't plain.
if (raw.plain === true && Object.keys(out).length === 0) out.plain = true;
Expand Down
Loading