Skip to content

Commit 2b2fb95

Browse files
committed
Add notification dot with label
1 parent 3349904 commit 2b2fb95

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

client/modules/IDE/components/VersionIndicator.jsx

+35-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from 'react';
1+
import React, { useCallback, useEffect, useState } from 'react';
22
import styled from 'styled-components';
33
import { useTranslation } from 'react-i18next';
44
import { useDispatch } from 'react-redux';
@@ -29,21 +29,51 @@ const VersionPickerButton = styled.button`
2929
}
3030
`;
3131

32+
const NotificationDot = styled.div`
33+
display: inline-block;
34+
vertical-align: top;
35+
border-radius: 50%;
36+
width: 0.7rem;
37+
height: 0.7rem;
38+
background-color: ${prop('colors.dodgerblue')};
39+
margin-left: 0.25rem;
40+
`;
41+
42+
const CLICKED_LIBRARY_VERSION_KEY = 'clickedLibraryVersionIndicator';
43+
3244
const VersionIndicator = () => {
3345
const { versionInfo } = useP5Version();
3446
const { t } = useTranslation();
3547
const dispatch = useDispatch();
48+
const [showNotificationDot, setShowNotificationDot] = useState(false);
49+
50+
useEffect(() => {
51+
const hasHiddenDot = window.localStorage.getItem(
52+
CLICKED_LIBRARY_VERSION_KEY
53+
);
54+
setShowNotificationDot(!hasHiddenDot);
55+
}, []);
3656

3757
const openVersionSettings = useCallback(() => {
3858
dispatch(openPreferences());
3959
dispatch(setPreferencesTab(2));
60+
setShowNotificationDot(false);
61+
window.localStorage.setItem(CLICKED_LIBRARY_VERSION_KEY, true);
4062
}, []);
4163

64+
const label = t('Toolbar.LibraryVersion');
65+
const currentVersion =
66+
versionInfo?.version || t('Toolbar.CustomLibraryVersion');
67+
let ariaLabel = `${label}: ${currentVersion}`;
68+
if (showNotificationDot) {
69+
ariaLabel = `${t('Toolbar.Notification')} - ${ariaLabel}`;
70+
}
71+
4272
return (
43-
<VersionPickerButton onClick={openVersionSettings}>
44-
{t('Toolbar.LibraryVersion')}
45-
&nbsp;
46-
{versionInfo?.version || t('Toolbar.CustomLibraryVersion')}
73+
<VersionPickerButton onClick={openVersionSettings} ariaLabel={ariaLabel}>
74+
{label}:&nbsp;
75+
{currentVersion}
76+
{showNotificationDot && <NotificationDot />}
4777
<EditIcon focusable="false" aria-hidden="true" />
4878
</VersionPickerButton>
4979
);

client/theme.js

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const baseThemes = {
7979
modalBorderColor: grays.middleLight,
8080
searchBackgroundColor: grays.lightest,
8181
tableRowStripeColor: grays.mediumLight,
82+
notification: colors.dodgerblue,
8283

8384
Button: {
8485
primary: {
@@ -170,6 +171,7 @@ const baseThemes = {
170171
modalBorderColor: grays.middleDark,
171172
searchBackgroundColor: grays.darker,
172173
tableRowStripeColor: grays.dark,
174+
notification: colors.processingBlueLight,
173175

174176
Button: {
175177
primary: {
@@ -257,6 +259,7 @@ export default {
257259
[Theme.contrast]: extend(baseThemes[Theme.dark], {
258260
inactiveTextColor: grays.light,
259261
logoColor: colors.yellow,
262+
notification: colors.p5ContrastYellow,
260263

261264
Button: {
262265
primary: {

translations/locales/en-US/translations.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@
157157
"EditSketchARIA": "Edit sketch name",
158158
"NewSketchNameARIA": "New sketch name",
159159
"By": " by ",
160-
"LibraryVersion": "p5.js version:",
161-
"CustomLibraryVersion": "Custom"
160+
"LibraryVersion": "p5.js version",
161+
"CustomLibraryVersion": "Custom",
162+
"Notification": "New"
162163
},
163164
"Console": {
164165
"Title": "Console",

0 commit comments

Comments
 (0)