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

[major] Introduce theming capacities #1323

Merged
merged 2 commits into from
Feb 4, 2024
Merged

[major] Introduce theming capacities #1323

merged 2 commits into from
Feb 4, 2024

Conversation

SBoudrias
Copy link
Owner

@SBoudrias SBoudrias commented Oct 22, 2023

This PR introduce theming capacity to Inquirer. This idea has been floating around multiple issues in the repo (#822, #1169, and others); but timing wasn't right for major API changes.

API changes

Inquirer users

From prompts user perspective, the default prompts (and hopefully the custom ones) will take an optional theme object config. That'll define how things are rendered.

Prompts can define their own extension to the theme object for their unique rendering.

Prompt authors (and internals)

Theme-ability is introduce with the makeTheme small utility. A default theme is always applied, but can be extended with each prompts specific theming needs.

Breaking changes

  1. @inquirer/core: usePrefix interface changed
  2. @inquirer/confirm: prefix config is removed in favour of theme.prefix
  3. @inquirer/checkbox: prefix config is removed in favour of theme.prefix

TODOs (to remove draft & ship)

  1. Document the feature in @inquirer/core for prompt authors
  2. Document the feature in each prompt for prompt users
  3. Write tests to cover theme-ability support
  4. Confirm typing doesn't cause issue & test them

Want to help? Comment on the PR with a task you'd like to take on. Open you PR against this PR (base: theme)

Out of scope

Though it is on my radar, I decided to not include an API to handle i18n for now. That'll likely come next with a similar config object but different internal API & types.

@SBoudrias SBoudrias marked this pull request as draft October 22, 2023 15:41
@codecov
Copy link

codecov bot commented Oct 22, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (6dda345) 94.39% compared to head (ab02f5f) 94.47%.

Files Patch % Lines
packages/editor/src/index.mts 0.00% 15 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           release-v2    #1323      +/-   ##
==============================================
+ Coverage       94.39%   94.47%   +0.07%     
==============================================
  Files              51       53       +2     
  Lines            4427     4558     +131     
  Branches          770      777       +7     
==============================================
+ Hits             4179     4306     +127     
- Misses            243      247       +4     
  Partials            5        5              

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

@SBoudrias SBoudrias merged commit 88daff9 into release-v2 Feb 4, 2024
13 of 14 checks passed
@SBoudrias SBoudrias deleted the theme branch February 4, 2024 18:22
SBoudrias added a commit that referenced this pull request Feb 4, 2024
* Breaking: Remove async message feature (#1322)

* BREAKING: Require Node >=18

* [major] Introduce theming capacities (#1323)

* Chore: Refactor usePrefix to rely on a new Theme construct

* Feat: Apply theming to all prompts

* Chore: Bump dependencies

* Fix: tsconfig.json formatting inconsistency
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.

None yet

1 participant