Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac-Flath committed Aug 16, 2024
1 parent fdfe8bc commit 34927a3
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 123 deletions.
2 changes: 1 addition & 1 deletion apps/our_card_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@

@app.get('/')
def home():
return Title("Custom"),Div(cls=('uk-child-width-1-3@l','uk-child-width-1-2@m'), uk_grid=True)(
return Title("Basic"),Div(cls=('uk-child-width-1-3@l','uk-child-width-1-2@m'), uk_grid=True)(
Div(cls='space-y-6')(map(Div,(Left1,Left2,GalleryCard))),
Div(cls='space-y-6')(map(Div,(Middle1,Middle2,Middle3,Middle4))),
Div(cls='space-y-6')(map(Div,(Right1,Right2, Right3))),
Expand Down
10 changes: 5 additions & 5 deletions apps/our_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
UkButton(cls=UkButtonT.default)(Span(cls="uk-margin-small-right", uk_icon="icon: github; ratio: 1"),'Github'),
UkButton(cls=UkButtonT.default)(Span(cls="uk-margin-small-right", uk_icon="icon: google; ratio: 1"),'Google')),
UkHSplit("OR CONTINUE WITH", text_cls = (TextB.xsmall, TextB.muted)),
UkInput('Email','', 'email',placeholder='[email protected]'),
UkInput('Password','', 'Password',placeholder='Password',type='Password'),
UkInput('Email', 'email',placeholder='[email protected]'),
UkInput('Password', 'Password',placeholder='Password',type='Password'),
header=(H3(cls='uk-h3')('Create an account'),P(cls=f'{TextT.muted_sm}')('Enter your email below to create your account')),
footer=UkButton(cls=(UkButtonT.primary,'w-full'))('Create Account'),
body_cls='space-y-4 py-0'
Expand All @@ -46,12 +46,12 @@
UkButton(Div(cls='flex flex-col items-center justify-center')(Card3Svg, "Apple"), cls='uk-button-default h-20 w-full')),

Div(cls=' space-y-4')(
UkInput('Name','', 'name',placeholder='[email protected]'),
UkInput('Card Number','', 'card_number',placeholder='[email protected]'),
UkInput('Name', 'name',placeholder='[email protected]'),
UkInput('Card Number', 'card_number',placeholder='[email protected]'),
Div(cls='grid grid-cols-3 gap-4')(
UkSelect(*month_opts,label='Expires',id='expire_month'),
UkSelect(*year_opts,label='Year',id='expire_year'),
UkInput('CVV','', 'cvv',placeholder='CVV'),
UkInput('CVV', 'cvv',placeholder='CVV'),
)),
header=(H3(cls='uk-h3')('Payment Method'),P(cls=f'{TextT.muted_sm}')('Add a new payment method to your account.')),
)
Expand Down
1 change: 1 addition & 0 deletions fh_frankenui/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'fh_frankenui.components.UkGenericInput': ( 'components.html#ukgenericinput',
'fh_frankenui/components.py'),
'fh_frankenui.components.UkHSplit': ('components.html#ukhsplit', 'fh_frankenui/components.py'),
'fh_frankenui.components.UkSelect': ('components.html#ukselect', 'fh_frankenui/components.py'),
'fh_frankenui.components.VEnum': ('components.html#venum', 'fh_frankenui/components.py'),
'fh_frankenui.components.VEnum.__add__': ( 'components.html#venum.__add__',
'fh_frankenui/components.py'),
Expand Down
50 changes: 32 additions & 18 deletions fh_frankenui/components.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_components.ipynb.

# %% auto 0
__all__ = ['UkInput', 'UkSwitch', 'UkTextArea', 'UkFormLabel', 'UkSelect', 'UkH1', 'UkH2', 'UkH3', 'UkH4', 'UkH5', 'UkH6',
'stringify', 'VEnum', 'TextB', 'TextT', 'Theme', 'UkGenericInput', 'UkDropdownButton', 'UkButtonT',
__all__ = ['UkInput', 'UkSwitch', 'UkTextArea', 'UkFormLabel', 'UkH1', 'UkH2', 'UkH3', 'UkH4', 'UkH5', 'UkH6', 'stringify',
'VEnum', 'TextB', 'TextT', 'Theme', 'UkGenericInput', 'UkSelect', 'UkButtonT', 'UkDropdownButton',
'UkButton', 'UkGenericComponent', 'UkHSplit', 'Card']

# %% ../nbs/01_components.ipynb 2
Expand Down Expand Up @@ -75,7 +75,7 @@ def headers(self):



# %% ../nbs/01_components.ipynb 21
# %% ../nbs/01_components.ipynb 22
def UkGenericInput(input_fn,
label=(),
lbl_cls=(),
Expand All @@ -91,12 +91,36 @@ def UkGenericInput(input_fn,
if id: res.id = id
return Div(cls=cls)(label, res)

# %% ../nbs/01_components.ipynb 22
# %% ../nbs/01_components.ipynb 23
UkInput = partial(UkGenericInput, partial(Input, cls='uk-input'))
UkSwitch = partial(UkGenericInput, partial(Input, cls='uk-toggle-switch uk-toggle-switch-primary', type='checkbox'))
UkTextArea = partial(UkGenericInput, partial(Textarea, cls='uk-textarea'))
UkFormLabel = partial(UkGenericInput, partial(Uk_input_tag, cls='uk-form-label'))
UkSelect = partial(UkGenericInput, partial(Uk_select, uk_cloak = True))

# %% ../nbs/01_components.ipynb 24
def UkSelect(*options,
label=(),
lbl_cls=(),
inp_cls=(),
cls=(), # Div cls
id="", **kwargs):
lbl_cls, inp_cls, cls = map(stringify,(lbl_cls, inp_cls, cls))
if label:
label = Label(cls='uk-form-label' + lbl_cls)(label)
if id: label.fr = id
res = Uk_select(cls=inp_cls, uk_cloak=True, **kwargs)(*options)
if id: res.id = id
return Div(cls=cls)(label, res)

# %% ../nbs/01_components.ipynb 25
class UkButtonT(VEnum):
default = 'default'
primary = 'primary'
secondary = 'secondary'
danger = 'danger'
ghost = 'ghost'
text = 'text'
link = 'link'

# %% ../nbs/01_components.ipynb 26
def UkDropdownButton(label, # Shown on the button
Expand All @@ -111,23 +135,13 @@ def UkDropdownButton(label, # Shown on the button
return Div(cls=cls)(Div(cls='flex items-center space-x-4')(btn, dd))

# %% ../nbs/01_components.ipynb 28
class UkButtonT(VEnum):
default = 'default'
primary = 'primary'
secondary = 'secondary'
danger = 'danger'
ghost = 'ghost'
text = 'text'
link = 'link'

# %% ../nbs/01_components.ipynb 29
def UkButton(*c,
cls=UkButtonT.default, # Use UkButtonT or styles
**kwargs):
return Button(cls='uk-button ' + stringify(cls), **kwargs)(*c)


# %% ../nbs/01_components.ipynb 30
# %% ../nbs/01_components.ipynb 29
def UkGenericComponent(component_fn, *c, cls=(), **kwargs):
res = component_fn(**kwargs)(*c)
if cls: res.attrs['class'] += ' ' + cls
Expand All @@ -141,14 +155,14 @@ def UkGenericComponent(component_fn, *c, cls=(), **kwargs):
UkH6 = partial(UkGenericComponent, partial(H6,cls='uk-h6'))


# %% ../nbs/01_components.ipynb 32
# %% ../nbs/01_components.ipynb 31
def UkHSplit(*c, cls=(), line_cls=(), text_cls=()):
cls, line_cls, text_cls = map(stringify,(cls, line_cls, text_cls))
return Div(cls='relative ' + cls)(
Div(cls="absolute inset-0 flex items-center " + line_cls)(Span(cls="w-full border-t border-border")),
Div(cls="relative flex justify-center " + text_cls)(Span(cls="bg-background px-2 ")(*c)))

# %% ../nbs/01_components.ipynb 34
# %% ../nbs/01_components.ipynb 33
def Card(*c, # Components that go in the body
header=None, # Components that go in the header
footer=None, # Components that go in the footer
Expand Down
Loading

0 comments on commit 34927a3

Please sign in to comment.