Skip to content

Commit

Permalink
Several fixes post refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
davepeck committed May 7, 2024
1 parent 1de3626 commit f5b81bb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions server/utils/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load_sibling_file(base_file_name: str | pathlib.Path, file_name: str) -> str

def _css_vars(selector: str, /, **vars: str) -> str:
"""Generate CSS variables to inject into a stylesheet."""
as_css = "\n".join(" --{k.replace('_', '-')}: {v};" for k, v in vars.items())
as_css = "\n".join(f" --{k.replace('_', '-')}: {v};" for k, v in vars.items())
return f"{selector} {{\n{as_css}\n}}\n"


Expand Down Expand Up @@ -69,7 +69,7 @@ def js(
as_json = json.dumps(as_camel)
element = element(data_props=as_json)
if surreal:
text = f"({text})(me(), me('script').dataset.props && JSON.parse(me('script').dataset.props))" # noqa: E501
text = f"({text})(me(), me().querySelector('script').dataset.props && JSON.parse(me().querySelector('script').dataset.props))" # noqa: E501
return element[Markup(text)]


Expand Down
3 changes: 2 additions & 1 deletion server/vb/components/check_page.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ me main .urgency {
}

me main .fireworks {
pointer-events: none;
position: absolute;
top: 0;
left: 0;
Expand All @@ -112,4 +113,4 @@ me main img {
me main .urgency {
flex-direction: row;
}
}
}
2 changes: 1 addition & 1 deletion server/vb/components/check_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def check_page(school: School, current_contest: Contest | None) -> h.Element:
countdown(current_contest)
if current_contest
else h.div(".separate")[
h.p["Check your voter registraiton status below."]
h.p["Check your voter registration status below."]
],
]
],
Expand Down
8 changes: 4 additions & 4 deletions server/vb/components/ongoing_contest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @param {HTMLElement} self
* @param {object} props
* @param {string} props.endAt
* @param {string} props.endsAt
*/

function ongoingCountdown(self, props) {
Expand All @@ -12,12 +12,12 @@ function ongoingCountdown(self, props) {
*
* @param {HTMLElement} self
* @param {object} props
* @param {string} props.endAt
* @param {string} props.endsAt
*/
function countdown(self, props) {
// compute the deadline
const { endAt } = props;
const deadline = new Date(endAt);
const { endsAt } = props;
const deadline = new Date(endsAt);
const deadlineTime = deadline.getTime();

/** Update the countdown. */
Expand Down
2 changes: 1 addition & 1 deletion server/vb/components/ongoing_contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def ongoing_contest(contest: Contest) -> h.Element:
)["Visit event"]
],
],
h.div(".box", data_end_at=contest.end_at.isoformat())[
h.div(".box")[
js(__file__, "ongoing_contest.js", ends_at=contest.end_at.isoformat()),
"Ends in ...",
],
Expand Down

0 comments on commit f5b81bb

Please sign in to comment.