-
Notifications
You must be signed in to change notification settings - Fork 36
Remove extra linebreak from core Block and python PythonBlock components #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@alloy-js/core" | ||
| --- | ||
|
|
||
| The `<Block>` component no longer emits an empty line when the `closer` prop is `false. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@alloy-js/python" | ||
| --- | ||
|
|
||
| The `<PythonBlock>` component no longer emits an empty line after it. Use an explicit `<hbr />` or `<List doubleHardline>` to recover the old formatting. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,9 +10,10 @@ export interface BlockProps { | |
| opener?: string; | ||
|
|
||
| /** | ||
| * The closing punctuation of the block. Defaults to "\}". | ||
| * The closing punctuation of the block. Defaults to "\}". When passed `false`, | ||
| * no closing punctuation will be added and there will be no trailing newline. | ||
| */ | ||
| closer?: string; | ||
| closer?: string | boolean; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider narrowing this to string | false instead of string | boolean. Only alse has defined special semantics here (suppress trailing break + render nothing). Passing rue would silently produce no visible closer but still emit a trailing break, which is an odd state that's hard to distinguish from the default. string | false communicates intent more precisely and prevents accidental misuse. |
||
|
|
||
| /** | ||
| * Whether the block starts on a new line. When true, a hardline is added | ||
|
|
@@ -41,7 +42,7 @@ export function Block(props: BlockProps) { | |
| <Indent | ||
| line={props.inline && childCount.value > 0} | ||
| softline={childCount.value === 0} | ||
| trailingBreak | ||
| trailingBreak={props.closer !== false} | ||
| > | ||
| {props.children} | ||
| </Indent> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: missing closing backtick after alse - should be
alsewith the closing tick.