From 5cf6aa997a337cbd3066a54b012918b55d3cba14 Mon Sep 17 00:00:00 2001 From: Bauke Date: Fri, 25 Feb 2022 14:47:20 +0100 Subject: [PATCH] Add an indicator for new features. --- source/options/features.ts | 10 ++++++++++ source/options/options.ts | 36 ++++++++++++++++++++++-------------- source/scss/index.scss | 11 +++++++++++ 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/source/options/features.ts b/source/options/features.ts index 0bac939..7a8a1a7 100644 --- a/source/options/features.ts +++ b/source/options/features.ts @@ -12,6 +12,7 @@ import { } from './components/exports.js'; type Feature = { + availableSince: Date; index: number; key: keyof RemoveIndexSignature; title: string; @@ -20,54 +21,63 @@ type Feature = { export const features: Feature[] = [ { + availableSince: new Date('2022-02-23'), index: 0, key: 'anonymizeUsernames', title: 'Anonymize Usernames', component: () => AnonymizeUsernamesSetting, }, { + availableSince: new Date('2020-10-03'), index: 0, key: 'autocomplete', title: 'Autocomplete', component: () => AutocompleteSetting, }, { + availableSince: new Date('2019-11-10'), index: 0, key: 'backToTop', title: 'Back To Top', component: () => BackToTopSetting, }, { + availableSince: new Date('2019-11-12'), index: 0, key: 'hideVotes', title: 'Hide Votes', component: () => HideVotesSetting, }, { + availableSince: new Date('2019-11-10'), index: 0, key: 'jumpToNewComment', title: 'Jump To New Comment', component: () => JumpToNewCommentSetting, }, { + availableSince: new Date('2019-11-12'), index: 0, key: 'markdownToolbar', title: 'Markdown Toolbar', component: () => MarkdownToolbarSetting, }, { + availableSince: new Date('2019-11-10'), index: 0, key: 'userLabels', title: 'User Labels', component: () => UserLabelsSetting, }, { + availableSince: new Date('2022-02-25'), index: 0, key: 'usernameColors', title: 'Username Colors', component: () => UsernameColorsSetting, }, { + availableSince: new Date('2019-11-10'), index: 1, key: 'debug', title: 'About & Info', diff --git a/source/options/options.ts b/source/options/options.ts index bc3a9aa..dae302b 100644 --- a/source/options/options.ts +++ b/source/options/options.ts @@ -33,6 +33,10 @@ type State = { class App extends Component { state: State; + // Duration for how long the "NEW" indicator should appear next to a feature, + // currently 14 days. + readonly newFeatureDuration = 14 * 24 * 60 * 60 * 1000; + constructor(props: Props) { super(props); @@ -96,21 +100,25 @@ class App extends Component { ); const tildesLink = html`<${Link} text="Tildes" url="${tildesURL}" />`; - const asideElements = features.map( - ({key, title}) => - html` -
  • NEW` + : undefined; + + return html` +
  • - ${title} -
  • - `, - ); + onClick="${() => { + this.setActiveFeature(key); + }}" + > + ${title}${isNew} + + `; + }); const mainElements = features.map( ({key, title, component}) => diff --git a/source/scss/index.scss b/source/scss/index.scss index 2847865..2c51110 100644 --- a/source/scss/index.scss +++ b/source/scss/index.scss @@ -115,6 +115,10 @@ details { background-color: var(--light-blue); border-color: var(--light-blue); cursor: pointer; + + .is-new { + color: var(--dark-blue); + } } &:not(:last-child) { @@ -134,6 +138,13 @@ details { margin-left: auto; } } + + .is-new { + color: var(--light-blue); + font-weight: bold; + font-size: 60%; + vertical-align: top; + } } }