Skip to content

Commit a984495

Browse files
authored
Merge pull request #20913 from calixteman/new_badge
Add a new badge close to the Manage button in the sidebar.
2 parents e65d643 + 85d88e5 commit a984495

5 files changed

Lines changed: 43 additions & 0 deletions

File tree

l10n/en-US/viewer.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,3 +779,7 @@ pdfjs-views-manager-paste-button-before =
779779
# $page (Number) - the page number after which the paste button is.
780780
pdfjs-views-manager-paste-button-after =
781781
.title = Paste after page { $page }
782+
783+
# Badge used to promote a new feature in the UI, keep it as short as possible.
784+
# It's spelled uppercase for English, but it can be translated as usual.
785+
pdfjs-new-badge-content = NEW

web/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ const PDFViewerApplication = {
600600
pageColors,
601601
abortSignal,
602602
enableSplitMerge,
603+
enableNewBadge: AppOptions.get("enableNewBadge"),
603604
statusBar: viewsManager.viewsManagerStatusBar,
604605
undoBar: viewsManager.viewsManagerUndoBar,
605606
manageMenu: viewsManager.manageMenu,

web/app_options.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ const defaultOptions = {
250250
value: true,
251251
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
252252
},
253+
enableNewBadge: {
254+
/** @type {boolean} */
255+
value: typeof PDFJSDev === "undefined" || PDFJSDev.test("MOZCENTRAL"),
256+
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
257+
},
253258
enableOptimizedPartialRendering: {
254259
/** @type {boolean} */
255260
value: false,

web/pdf_thumbnail_viewer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ const SPACE_FOR_DRAG_MARKER_WHEN_NO_NEXT_ELEMENT = 15;
6464
* mode.
6565
* @property {AbortSignal} [abortSignal] - The AbortSignal for the window
6666
* events.
67+
* @property {boolean} [enableNewBadge] - Enables the "new" badge for the split
68+
* and merge features.
6769
* @property {boolean} [enableSplitMerge] - Enables split and merge features.
6870
* The default value is `false`.
6971
* @property {Object} [statusBar] - The status bar elements to manage the status
@@ -172,6 +174,7 @@ class PDFThumbnailViewer {
172174
pageColors,
173175
abortSignal,
174176
enableSplitMerge,
177+
enableNewBadge,
175178
statusBar,
176179
undoBar,
177180
manageMenu,
@@ -207,6 +210,14 @@ class PDFThumbnailViewer {
207210
delete: del,
208211
exportSelected,
209212
} = manageMenu;
213+
214+
if (enableNewBadge) {
215+
const newSpan = document.createElement("span");
216+
newSpan.setAttribute("data-l10n-id", "pdfjs-new-badge-content");
217+
newSpan.classList.add("newBadge");
218+
button.parentElement.before(newSpan);
219+
}
220+
210221
this.eventBus.on(
211222
"pagesloaded",
212223
() => {

web/pdf_viewer.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,38 @@
3636
--loading-icon-delay: 400ms;
3737
--focus-ring-color: light-dark(#0060df, #0df);
3838
--focus-ring-outline: 2px solid var(--focus-ring-color);
39+
--new-badge-bg: light-dark(#070, #37b847);
40+
--new-badge-color: light-dark(#fff, #15141a);
41+
--new-badge-border-color: light-dark(#fbfbfe / 40%, #15141a / 40%);
3942

4043
@media screen and (forced-colors: active) {
4144
--pdfViewer-padding-bottom: 9px;
4245
--page-margin: 8px auto -1px;
4346
--page-border: 1px solid CanvasText;
4447
--spreadHorizontalWrapped-margin-LR: 3.5px;
4548
--focus-ring-color: CanvasText;
49+
--new-badge-bg: AccentColor;
50+
--new-badge-color: ButtonFace;
51+
--new-badge-border-color: CanvasText;
4652
}
4753
}
4854

55+
.newBadge {
56+
background-color: var(--new-badge-bg);
57+
color: var(--new-badge-color);
58+
border-radius: 4px;
59+
border: 1px solid var(--new-badge-border-color);
60+
padding-inline: 4px;
61+
margin-inline: 4px;
62+
font: menu;
63+
font-size: 12px;
64+
font-style: normal;
65+
font-weight: 400;
66+
line-height: normal;
67+
flex: 0 0 fit-content;
68+
user-select: none;
69+
}
70+
4971
[data-main-rotation="90"] {
5072
transform: rotate(90deg) translateY(-100%);
5173
}

0 commit comments

Comments
 (0)