-
-
Save johanalkstal/7c0d2fd29d712e95bfea0e75fd85b200 to your computer and use it in GitHub Desktop.
ScrollArea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FlexLayout, QBoxLayout, QLabel, QScrollArea, QWidget, ScrollBarPolicy } from "@nodegui/nodegui" | |
import { Color, Space, TextSize } from "../style/variables" | |
class MessageList extends QScrollArea { | |
constructor() { | |
super() | |
this.setVerticalScrollBarPolicy(ScrollBarPolicy.ScrollBarAlwaysOn) | |
this.setWidgetResizable(true) | |
this.setInlineStyle(` | |
flex: 1; | |
`) | |
const container = new QWidget() | |
container.setLayout(new FlexLayout()) | |
container.setInlineStyle(` | |
background-color: ${Color.white}; | |
flex-direction: column; | |
padding: ${Space.md}; | |
`) | |
container.setStyleSheet(` | |
QLabel { | |
font-size: ${TextSize.sm}; | |
margin-bottom: ${Space.xs}; | |
min-height: 18px; | |
} | |
`) | |
this.setWidget(container) | |
} | |
addMessage(message: string, color = Color.black) { | |
const label = new QLabel() | |
label.setText(message) | |
label.setInlineStyle(` | |
color: ${color}; | |
`) | |
this.contentWidget?.layout?.addWidget(label) | |
} | |
} | |
export default MessageList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment