Skip to content
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

feat: add aliases for custom layout of notification banner #91

Merged
merged 5 commits into from
Dec 24, 2024
Merged

Conversation

JarKz
Copy link
Contributor

@JarKz JarKz commented Dec 21, 2024

Motivation

To avoid any duplication of declarations, need to introduce alias keyword for custom layout. It will make the declaration more clean than earlier, also using simple words will simplify understanding the meaning of layout.

Related issues

Closes #75

Changes

  • Added derive for GenericBuilder.
  • Added safe check in text-compile because the empty lines will adds until available space won't remains.
  • Implemented alias keyword for custom layout definition.
  • Extended GenericBuilder by adding associated builders using macro attribute use_gbuilder which should help conversion of custom layout into widgets.

Syntax of aliases

Alias is like a variable but it stores metadata of Widget or Type Value. The metadata are reusable and overrideable if needed. All of aliases should be defined before main Widget. Here's an example:

alias Center = Alignment(horizontal = center, vertical = center)
alias CenteredText = Text(justification = center)
alias ItalicCenteredText = CenteredText(style = italic)

alias Title = ItalicCenteredText(kind = title)
alias Body = Text(kind = body, justification = left)

alias Row = FlexContainer(direction = horizontal)
alias Column = FlexContainer(direction = vertical)

Row(
  alignment = Center(),
) {
  Image()
  Column(
    alignment = Center(vertical = start), // We can override the Center alias
  ) {
    Title(font_size = 22)
    Body(font_size = 18)
  }
}

Addition

With it also updated tree-sitter parser at noti-rs/tree-sitter-noti@783911e.
Updated NeoVim plugin noti.nvim: noti-rs/noti.nvim@cfe3099.

@JarKz JarKz merged commit 2a75528 into main Dec 24, 2024
5 checks passed
@JarKz JarKz deleted the ft-aliases branch December 24, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add alias syntax for .noti filetype
2 participants