Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Record passed status for challenges #80

Merged
merged 17 commits into from
Jan 24, 2024

Conversation

100gle
Copy link
Contributor

@100gle 100gle commented Dec 24, 2023

Closed #78

@100gle 100gle force-pushed the add-passed-status branch 2 times, most recently from 9c4c172 to e2328ad Compare December 24, 2023 14:06
@100gle 100gle marked this pull request as ready for review December 28, 2023 11:48
@100gle 100gle changed the title [WIP] feat: Record passed status for challenges feat: Record passed status for challenges Dec 28, 2023
@100gle
Copy link
Contributor Author

100gle commented Dec 28, 2023

@laike9m 搜了一下 jotai 似乎没有直接通过 CDN 引入然后直接使用的示例或相关文档,所以我就没有暂时没有尝试了;最后简单实现了一下效果如下所示:

屏幕录制2023-12-28 19 43 27

完成的 icon 放在了右侧,这样就可以暂时不用动 Sidebar 里面文字的布局了,比较省时省力

@laike9m
Copy link
Owner

laike9m commented Jan 19, 2024

Sorry, I thought this PR is WIP so I didn't review it. Is it ready for review?

@100gle
Copy link
Contributor Author

100gle commented Jan 19, 2024

Sorry, I thought this PR is WIP so I didn't review it. Is it ready for review?

Yes, it is.

@laike9m
Copy link
Owner

laike9m commented Jan 22, 2024

The original density of the challenge list feels right to me, I'd rather we don't change it. Could you change it back?

I haven't finished reading the implementation, should be done tomorrow.

@100gle
Copy link
Contributor Author

100gle commented Jan 22, 2024

Density? Which part of css style do you refer? Padding, margin or width?

@laike9m
Copy link
Owner

laike9m commented Jan 23, 2024

Old

image

New

image

See the paddings in the left sidebar

static/js/passed-state.js Outdated Show resolved Hide resolved
templates/components/challenge_area.html Outdated Show resolved Hide resolved
Copy link
Owner

@laike9m laike9m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A design question:

Right now we basically have two copies of state, one in PassedState._state, one in localStorage. There's a bunch of code just for syncing the two states.

I'm wondering, is it possible to remove PassedState._state, and just use localStorage as the single source of truth? e.g. when a test passed, update localStorage directly. I feel if implemented this way, the code can be hugely simplified.

Performance should be the same, since we need to update localStorage anyway. Even if not, it shouldn't matter here.

See if it makes sense to you. Happy to discuss more.

@100gle 100gle force-pushed the add-passed-status branch from 81d6f8e to f48e964 Compare January 23, 2024 11:35
@100gle
Copy link
Contributor Author

100gle commented Jan 23, 2024

A design question:

Right now we basically have two copies of state, one in PassedState._state, one in localStorage. There's a bunch of code just for syncing the two states.

I'm wondering, is it possible to remove PassedState._state, and just use localStorage as the single source of truth? e.g. when a test passed, update localStorage directly. I feel if implemented this way, the code can be hugely simplified.

Performance should be the same, since we need to update localStorage anyway. Even if not, it shouldn't matter here.

See if it makes sense to you. Happy to discuss more.

@laike9m Done

@laike9m
Copy link
Owner

laike9m commented Jan 23, 2024

Is it possible to reduce the empty space between challenge name and the check mark?

image

The sidebar is a lot wider than before

templates/components/challenge_sidebar.html Outdated Show resolved Hide resolved
templates/components/challenge_area.html Show resolved Hide resolved
static/js/passed-state.js Outdated Show resolved Hide resolved
static/js/passed-state.js Outdated Show resolved Hide resolved
@100gle 100gle requested a review from laike9m January 23, 2024 16:01
Copy link
Owner

@laike9m laike9m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bug with challenge selection: previous highlight does not disappear

image

static/js/passed-state.js Show resolved Hide resolved
templates/components/challenge_area.html Outdated Show resolved Hide resolved
templates/components/challenge_sidebar.html Outdated Show resolved Hide resolved
static/js/passed-state.js Outdated Show resolved Hide resolved
static/js/passed-state.js Outdated Show resolved Hide resolved
@100gle
Copy link
Contributor Author

100gle commented Jan 24, 2024

There's a bug with challenge selection: previous highlight does not disappear

image

This is because we set <script type="module"></script> to import passedState from a module, so element can't refer the global removeHighlight function, it has been put to local scope.

@100gle
Copy link
Contributor Author

100gle commented Jan 24, 2024

There's a bug with challenge selection: previous highlight does not disappear
image

This is because we set <script type="module"></script> to import passedState from a module, so element can't refer the global removeHighlight function, it has been put to local scope.

I have fixed this bug temporarily by splitting the one script tag in challenge-sidebar.html into modular and global script tag.

But some unknown potential issues will be raised in sometime because of the scope. For this situation, maybe the better choice is to switch to JavaScript tool(like Vite) to solve.

static/js/passed-state.js Outdated Show resolved Hide resolved
@laike9m
Copy link
Owner

laike9m commented Jan 24, 2024

There's a bug with challenge selection: previous highlight does not disappear
image

This is because we set <script type="module"></script> to import passedState from a module, so element can't refer the global removeHighlight function, it has been put to local scope.

I have fixed this bug temporarily by splitting the one script tag in challenge-sidebar.html into modular and global script tag.

But some unknown potential issues will be raised in sometime because of the scope. For this situation, maybe the better choice is to switch to JavaScript tool(like Vite) to solve.

I think at this point, bringing in tools like Vite might beneficial (with the assumption that it doesn't increase the complexity of managing things. btw TS is still a no-go). I can take a look at it.

The bigger concern is whether Zeabur supports a project with both Python and Node.js environment. I'm not so sure @MichaelYuhe

@laike9m laike9m merged commit 1ff014b into laike9m:main Jan 24, 2024
1 check passed
@100gle 100gle deleted the add-passed-status branch January 24, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Record and show passed challenges
2 participants