Skip to content

Commit 33e1fa6

Browse files
committed
Add named styles to buttons
1 parent 106d6c5 commit 33e1fa6

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

demo/components_list.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class Delivery(BaseModel):
8888
c.Heading(text='Button and Modal', level=2),
8989
c.Paragraph(text='The button below will open a modal with static content.'),
9090
c.Button(text='Show Static Modal', on_click=PageEvent(name='static-modal')),
91+
c.Button(text='Secondary Button', mode='secondary', class_name='+ ms-2'),
92+
c.Button(text='Warning Button', mode='warning', class_name='+ ms-2'),
9193
c.Modal(
9294
title='Static Modal',
9395
body=[c.Paragraph(text='This is some static content that was set when the modal was defined.')],

src/npm-fastui-bootstrap/src/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ export const classNameGenerator: ClassNameGenerator = ({
2828
case 'Page':
2929
return 'container mt-80'
3030
case 'Button':
31-
return 'btn btn-primary'
31+
return {
32+
btn: true,
33+
'btn-primary': !props.mode || props.mode === 'primary',
34+
'btn-secondary': props.mode === 'secondary',
35+
'btn-warning': props.mode === 'warning',
36+
}
3237
case 'Table':
3338
switch (subElement) {
3439
case 'no-data-message':

src/python-fastui/fastui/components/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class Button(_p.BaseModel, extra='forbid'):
152152
default=None, serialization_alias='htmlType'
153153
)
154154
class_name: _class_name.ClassNameField = None
155+
mode: _t.Union[_t.Literal['primary', 'secondary', 'warning'], None] = None
155156
type: _t.Literal['Button'] = 'Button'
156157

157158

0 commit comments

Comments
 (0)