From 5a8e8b0bd31dc2c5e8f3b83dc9825aefd7376eb1 Mon Sep 17 00:00:00 2001 From: Aljoscha Meyer Date: Wed, 17 Jan 2024 00:48:22 +0100 Subject: [PATCH] Do not indent struct member previews anymore --- pseudocode.ts | 17 ++++++++++------- willowtest/typography.css | 4 ++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pseudocode.ts b/pseudocode.ts index 1b91864..e314bd3 100644 --- a/pseudocode.ts +++ b/pseudocode.ts @@ -181,12 +181,14 @@ function item_spacing(): Expression { function render_line(...exps: Expression[]): Expression { const macro = new_macro( (args, ctx) => { - return div( - { class: "loc" }, - div({ - style: `margin-left: ${2 * pseudocode_state(ctx).indentation}rem;`, - }, ...args), - ); + const indentation = pseudocode_state(ctx).indentation; + let content: Expression = [...args]; + + for (let i = 0; i < indentation; i++) { + content = div({class: "locindent"}, content); + } + + return div({class: "loc"}, content); }, ); @@ -372,7 +374,8 @@ function render_struct(struct: Struct): Expression { type_name, ), indent( - struct.fields.map(render_field), + div({class: "composite_type_def"}, struct.fields.map(render_field)), + // struct.fields.map(render_field), ), ]; }, diff --git a/willowtest/typography.css b/willowtest/typography.css index 2533b72..60fb438 100644 --- a/willowtest/typography.css +++ b/willowtest/typography.css @@ -107,6 +107,10 @@ code.pseudocode { margin-top: 0; } +.composite_type_def .locindent { + margin-left: 2rem; +} + .preview code.pseudocode { margin: 0; }