Skip to content

Add card stack component #2648

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

Merged
merged 27 commits into from
Apr 10, 2025
Merged

Conversation

Incogdino
Copy link
Contributor

@Incogdino Incogdino commented Mar 16, 2025

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Closes #2553

Overview of changes:
Add CardStack Component

Anything you'd like to highlight/discuss:

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Add CardStack component

Features:

  1. Allow users to define cards, supporting markbind elements
  2. Searchable by tag, keywords and header
  3. Ability to disable cards without removing content from md file
  4. Ability to specify number of rows per block

Current limitations:

  1. Color of tags are limited to 8 unique colors due to the use of
    markbind's badge which inherently uses bootstrap's badge.
  2. Not searchable based on body text
  3. (Potential limitation) Limited support for number of columnss.
    Since bootstrap grid is used, the number of columns allowed is
    limited to 5 preset values.

Left to do:

  1. Add search feature icons to docs, related to Provide a search feature for icons #2553
  2. Update to Vue 3
  3. Update tags implementation

Future improvements:

  1. Allow users to specify custom background colours
  2. Allow users to specify search pattern (OR/ AND search)
  3. Add ids to cards to allow the cards to be specified elsewhere

Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

The CardStack component contains cards that can be specified using
Markbind's custom components. The CardStack component comes contains
a search feature to filter through the cards identified using tags
and keywords.
Tag colouring help to provide better visual appeal to the tags.

Due to the use of bootstrap badge for tags, the choice of color is
limited to 8 different colors. If there are more than 8 tags, the
color will recycle, making the tag coloration non unique.

In future, we can consider
1. adding more color schemes.
2. making the tags clickable as a button to filter search cards.
Previously, faces the following issues:
1. Does not allow header to be part of the search fields.
2. Collects search information prior to each search input.

The search feature now allows headers to be part of the search
field and preprocesses the search data on mount.
Previous version of card stack does not allow users to search by tag.
Changes added:
1. Add search by tags (click activated)
2. Update snapshots
1. Added handling for erroneous block values (fallback to closet
predefined values).
2. Update format to include space when displaying keywords.
3. Update supported block values for cardstack in docs.
@Incogdino Incogdino marked this pull request as ready for review March 22, 2025 07:42
@Incogdino Incogdino requested a review from lhw-1 March 22, 2025 13:23
@gerteck
Copy link
Contributor

gerteck commented Mar 23, 2025

This looks like a really cool and useful feature!

Play around with it here:

@AgentHagu
Copy link
Contributor

There is some weird behavior with the searchbar of the card stack. It seems to only search using the last word in the search bar. For example, consider this sequence of searches:

  1. Basic
  2. Basic card
  3. Basic card question

The expected behavior depends on whether the searchbar should be an OR or an AND search but either way, the actual behavior doesn't seem to follow either. The actual behavior seems to be that the searchbar only uses the last word, so for 1, 2 and 3, it searches "basic", "card" and "question" respectively. Is this intended behavior? Screenshots below:

image
image
image

@lhw-1
Copy link
Contributor

lhw-1 commented Mar 27, 2025

In terms of the tags, the current implementation seems to be an OR implementation; I am thinking if AND is more intuitive. Perhaps we could also provide a way to choose between the two behaviors? And as a nit, in terms of the design, adding some space between the "Tags:" and the actual tags would be nice.

That aside, as @AgentHagu pointed out, the behavior of the search bar is rather unintuitive. Filtering based on the last keyword seems to be the current behavior, which is rather unexpected.

E.g. this would not be the expected result for users, I would imagine:

image

@Incogdino What are your thoughts?

lhw-1 and others added 3 commits March 28, 2025 09:39
Search feature now searches for all matches with the specified
value instead of just the last word.
@Incogdino
Copy link
Contributor Author

In terms of the tags, the current implementation seems to be an OR implementation; I am thinking if AND is more intuitive. Perhaps we could also provide a way to choose between the two behaviors?

I discussed this with prof @damithc the other day during lecture and the consensus was that an OR search would better fit the purpose here since users are most likely going to filter according to what they want to appear in the card stack. As for whether we should allow users to choose between AND/ OR tag search, it is a good idea and I think we should have it too but it might lead to some inconsistencies in the final site when multiple card stacks are involved in the application and users toggle between them.

And as a nit, in terms of the design, adding some space between the "Tags:" and the actual tags would be nice.

Will work on this!

That aside, as @AgentHagu pointed out, the behavior of the search bar is rather unintuitive. Filtering based on the last keyword seems to be the current behavior, which is rather unexpected.

I have fixed this issue in the latest commit.

@damithc
Copy link
Contributor

damithc commented Mar 30, 2025

As for whether we should allow users to choose between AND/ OR tag search, it is a good idea and I think we should have it too but it might lead to some inconsistencies in the final site when multiple card stacks are involved in the application and users toggle between them.

This can be added as a nice-to-have feature, at a later time. The option to toggle between the two modes can be provided near the tick boxes (see below), so that it applies to the specific stack, not site-wide?
image

Incogdino and others added 2 commits March 30, 2025 15:57
- Removed overly complex documentation in favor of simpler and more
realistic use case of the card stack component.
- Added more details into the description of the component.
@lhw-1 lhw-1 added the r.Minor Version resolver: increment by 0.1.0 label Mar 30, 2025
1. Updated tags to flow with the search bar and overflow under it.
2. Updated snapshots.
@lhw-1 lhw-1 added this to the v6.1.0 milestone Mar 30, 2025
Incogdino and others added 2 commits March 30, 2025 21:02
Key changes made:
- Removal of $children -> changed to provide/inject
@lhw-1
Copy link
Contributor

lhw-1 commented Apr 1, 2025

I see that the latest commit is updating this feature to Vue 3 - is the PR ready for review?

@Incogdino
Copy link
Contributor Author

I see that the latest commit is updating this feature to Vue 3 - is the PR ready for review?

Let me update the docs to include the icons that markbind supports (for #2553)

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 64 lines in your changes missing coverage. Please review.

Project coverage is 51.90%. Comparing base (c474a43) to head (7f6b386).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/vue-components/src/cardstack/Card.vue 17.85% 46 Missing ⚠️
...ackages/vue-components/src/cardstack/CardStack.vue 62.85% 13 Missing ⚠️
packages/core/src/html/NodeProcessor.ts 0.00% 3 Missing ⚠️
packages/core/src/html/MdAttributeRenderer.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2648      +/-   ##
==========================================
- Coverage   52.16%   51.90%   -0.27%     
==========================================
  Files         128      130       +2     
  Lines        6999     7104     +105     
  Branches     1546     1570      +24     
==========================================
+ Hits         3651     3687      +36     
- Misses       3049     3118      +69     
  Partials      299      299              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Incogdino
Copy link
Contributor Author

I see that the latest commit is updating this feature to Vue 3 - is the PR ready for review?

Could we review this pr for now and leave #2553 on hold in the meantime. I am trying to find a way to retireve all the icon names without having to manually copy and paste them from the source itself.

If anyone has any ideas, please do let me know!

@lhw-1
Copy link
Contributor

lhw-1 commented Apr 3, 2025

I see, so we possibly merge the feature in first and leave the actual implementation on the MarkBind documentation to another PR later on. Sure, let's do that and keep this PR to introducing the new feature only.

Copy link
Contributor

@lhw-1 lhw-1 left a comment

Choose a reason for hiding this comment

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

LGTM, the feature works well; I couldn't find any regressions. Features like selecting between AND / OR, as well as using this for icons, can be followed-up in later PRs. Thanks @Incogdino!

Copy link
Contributor

@gerteck gerteck left a comment

Choose a reason for hiding this comment

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

Looks good to me too!

@lhw-1 lhw-1 merged commit fd83ef5 into MarkBind:master Apr 10, 2025
8 of 10 checks passed
Copy link

@lhw-1 Each PR must have a SEMVER impact label, please remember to label the PR properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r.Minor Version resolver: increment by 0.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a search feature for icons
5 participants