kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Update AttandanceBlock KButton to KRouterLink

Open rtibbles opened this issue 8 months ago • 6 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Update AttendanceBlock KButton to KRouterLink while maintaining styling.

Complexity: Low Target branch: release-v0.19.x

The Change

Change the KButton here: https://github.com/learningequality/kolibri/blob/6691db5ce055a70f62089b229f4336b409ec7cd7/kolibri/plugins/coach/frontend/views/home/HomePage/AttendanceBlock.vue#L13

To a KRouterLink - but ensure there is no change in visual styling. See the documentation for how to have the same button-like styling: https://design-system.learningequality.org/krouterlink#prop:appearance

Out of Scope

  • Any changes to the route it links to
  • Any changes to appearance

Acceptance Criteria

  • [ ] Uses KRouterLink instead of KButton
  • [ ] Visual appearance remains the same

Testing

Take a screenshot before and after.

rtibbles avatar Mar 13 '26 19:03 rtibbles

Implementation Plan

Goal: Replace KButton with KRouterLink in AttendanceBlock.vue while maintaining identical visual styling.

Approach: Both components share the same appearance, primary, text, and :to props. The appearance="raised-button" prop ensures the KRouterLink renders with button styling. This is a near-drop-in replacement.

Phase 1: Update the component

  • Swap import from KButton to KRouterLink (same kolibri-design-system/lib/buttons-and-links/ path)
  • Update components registration
  • Change <KButton> tag to <KRouterLink> in template (all props stay the same)

Phase 2: Update tests

  • Remove unused KButton stub from test file (the KRouterLink stub already exists)
  • Verify all 8 existing tests pass

Phase 3: Verify and commit

  • Run linter and tests
  • Commit

Files modified:

  • kolibri/plugins/coach/frontend/views/home/HomePage/AttendanceBlock.vue
  • kolibri/plugins/coach/frontend/views/home/HomePage/__tests__/AttendanceBlock.spec.js

Risk: Very low — simple component swap with shared props interface. No behavioral changes.

rtibblesbot avatar Mar 13 '26 20:03 rtibblesbot

Note that K* components are preregistered anyway, so there's never any need to import them on a per component basis.

rtibbles avatar Mar 13 '26 20:03 rtibbles

Implementation Complete

Replaced KButton with KRouterLink in AttendanceBlock.vue.

Changes

  • AttendanceBlock.vue: Swapped import, component registration, and template tag from KButton to KRouterLink. All props (text, primary, appearance="raised-button", :to) remain identical — both components inherit these from the shared buttonMixin.
  • AttendanceBlock.spec.js: Removed the now-unused KButton stub. The existing KRouterLink stub already covered the component.

Verification

  • Tests: 8/8 pass
  • Lint: 2 files linted, 0 errors
  • Visual styling: No change — KRouterLink with appearance="raised-button" and primary renders identically to KButton with the same props (confirmed via shared buttonMixin in kolibri-design-system)

Branch: issue-14380-743515

rtibblesbot avatar Mar 13 '26 20:03 rtibblesbot

Self-Review Complete

Findings & Fixes

suggestion (fixed): Per @rtibbles' feedback, K* components are preregistered by KThemePlugin and don't need per-component imports. Removed the KRouterLink import (which had replaced the KButton import) and also removed the pre-existing KCircularLoader import and both their components registrations. Committed in 2fb9ac9726.

No blocking issues found. The template tag swap from KButton to KRouterLink is correct — all props (text, primary, appearance="raised-button", :to) are shared via buttonMixin, ensuring identical visual styling.

Verification

  • 8/8 tests pass
  • Lint clean (1 file, 0 errors)
  • Final diff: 2 files, 1 insertion, 10 deletions

Acceptance Criteria

  • [x] Uses KRouterLink instead of KButton
  • [x] Visual appearance remains the same (appearance="raised-button" + primary preserved)
  • [x] No changes to route or appearance
  • [x] Tests pass, lint clean

rtibblesbot avatar Mar 13 '26 20:03 rtibblesbot

Thanks for the note about K* components being pre-registered globally, @rtibbles. The PR at #14381 incorporates this — it removes the unnecessary KButton and KCircularLoader imports and component registrations in addition to swapping KButton → KRouterLink with appearance="raised-button" to maintain styling.

rtibblesbot avatar Mar 13 '26 20:03 rtibblesbot

Fixed in #14381

rtibbles avatar Mar 13 '26 20:03 rtibbles