Skip to content

Commit

Permalink
Add CSS and a crappy non-spinning spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
intellectronica committed Aug 30, 2024
1 parent c8b3f19 commit 415ee90
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
10 changes: 10 additions & 0 deletions app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.htmx-indicator{
opacity:0;
transition: opacity 500ms ease-in;
}
.htmx-request .htmx-indicator{
opacity:1;
}
.htmx-request.htmx-indicator{
opacity:1;
}
16 changes: 13 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ def app_js():
with open('app.js') as f:
return f.read()

def app_css():
with open('app.css') as f:
return f.read()

app, rt = fast_app(
hdrs=[Script(app_js())],
hdrs=[Script(app_js()), Style(app_css())],
)

@app.post('/-/fetch-text')
Expand Down Expand Up @@ -80,7 +84,10 @@ def home():
B('URL'),
Input(name='url', type='text', id='url'),
),
Button('Fetch Text', hx_post='/-/fetch-text', hx_target='#text', hx_swap='innerHTML'),
Div(
P('⚙️', cls='htmx-indicator', id='fetch_spinner'),
Button('Fetch Text', hx_post='/-/fetch-text', hx_target='#text', hx_swap='innerHTML', hx_indicator='#fetch_spinner'),
)
),
Div(
B('Text'),
Expand All @@ -95,7 +102,10 @@ def home():
B('Tags'),
Input(name='tags', type='text', id='tags'),
),
Button('Generate Flashcards', hx_post='/-/generate-flashcards', hx_target='#flashcards', hx_swap='innerHTML'),
Div(
P('⚙️', cls='htmx-indicator', id='generate_spinner'),
Button('Generate Flashcards', hx_post='/-/generate-flashcards', hx_target='#flashcards', hx_swap='innerHTML', hx_indicator='#generate_spinner'),
),
),
Div(
B('Flashcards'),
Expand Down

0 comments on commit 415ee90

Please sign in to comment.