From f96d2e4546549f2d8025a14866a3da29697e3afa Mon Sep 17 00:00:00 2001 From: Toni Biocic Date: Mon, 30 Nov 2026 23:05:31 +0100 Subject: [PATCH] The Library's gift button, right of its back arrow as in Arc, opens Share Cra with a Friend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Arc's Library has a gift button at its foot, right of the back arrow, that opens "Share Arc with a friend". Cra's had the arrow alone, and its Share Cra with a Friend sheet only on Settings' first tab. The button is now there, 32×32 pt at x 73 on the arrow's row (Arc 1.170's AX frame: the arrow's place mirrored against the 113 pt rail), drawn as the arrow is: the gift symbol at 15 pt in the sidebar's glyph tone, the same hover fill, and the tip "Share Cra with a friend", the sheet's own title. CraCore LibraryRailTile.backFrame and giftFrame place both. Arc had it, so no setting gates it, and an incognito window's Library has it too. The click opens the sheet Settings opens, on the browser window, with the Library left open under it (MainWindowController.showShareCra, through DialogPanel like the other sheets AppKit hangs on a window; a sheet already up keeps it from opening). SwiftUI's dismiss closes only what SwiftUI presented, so ShareCraSheet takes an optional close, which its × and Escape call; Settings passes none, and its sheet is as before. Tests: LibraryRailIconsTests.theGiftButtonSitsRightOfTheBackArrowAsArcs (with the gift beside the arrow at x 48 it fails on x 73 and on the 8 pt to the rail's edge); scenario library-gift (the button's glyph, tip and place by the arrow's, the sheet on the window, no second one while it is up, none after endSheets, the Library still open). cra://debug adds libraryGift. --- .../Sources/CraCore/LibraryRailIcons.swift | 17 ++++++++++ .../CraCoreTests/LibraryRailIconsTests.swift | 12 +++++++ Sources/Cra/App/AppDelegate.swift | 7 ++++ Sources/Cra/UI/Settings/MemberCardView.swift | 5 ++- Sources/Cra/UI/Sidebar/LibraryView.swift | 33 ++++++++++++++++--- Sources/Cra/UI/Sidebar/List/SidebarView.swift | 2 ++ Sources/Cra/UI/SidebarUIState.swift | 2 ++ .../Cra/UI/Windows/MainWindowController.swift | 9 +++++ Tests/Scenarios/library-gift.scenario | 25 ++++++++++++++ docs/arc-parity.md | 2 +- docs/arc-reverse-engineering.md | 2 ++ 11 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 Tests/Scenarios/library-gift.scenario diff --git a/Packages/CraCore/Sources/CraCore/LibraryRailIcons.swift b/Packages/CraCore/Sources/CraCore/LibraryRailIcons.swift index d2cb95c2a..f80b6bd54 100644 --- a/Packages/CraCore/Sources/CraCore/LibraryRailIcons.swift +++ b/Packages/CraCore/Sources/CraCore/LibraryRailIcons.swift @@ -568,6 +568,23 @@ public enum LibraryRailTile { return Column(top: top, slot: slot, tileHeight: tile, showsLabel: slot > labelSlotFloor) } + /// The rail's foot (Arc 1.170, AX frames, 27 Oct 2026): the back arrow, 32 × 32 pt at x 8 and 8 pt above the + /// bottom, leaves the Library; the gift button at x 73, the arrow's place mirrored against the 113 pt rail, opens + /// Share Cra with a Friend where Arc's opens "Share Arc with a friend". + public static let footButton: CGFloat = 32 + public static let footInset: CGFloat = 8 + + /// The back arrow in a rail `railHeight` tall, from the rail's top-left. + public static func backFrame(railHeight: CGFloat) -> CGRect { + CGRect(x: footInset, y: railHeight - footInset - footButton, width: footButton, height: footButton) + } + + /// The gift button: on the back arrow's row, as far in from the rail's right edge as the arrow is from its left. + public static func giftFrame(railHeight: CGFloat) -> CGRect { + CGRect(x: CGFloat(LibraryWidth.rail) - footInset - footButton, y: railHeight - footInset - footButton, + width: footButton, height: footButton) + } + /// The sidebar's ink is the system's label colour: white on a dark theme and black on a light one, /// at this strength. The tile's wash and its label are shares of it. public static let inkStrength = 0.85 diff --git a/Packages/CraCore/Tests/CraCoreTests/LibraryRailIconsTests.swift b/Packages/CraCore/Tests/CraCoreTests/LibraryRailIconsTests.swift index 3fbbf0509..d8752e26b 100644 --- a/Packages/CraCore/Tests/CraCoreTests/LibraryRailIconsTests.swift +++ b/Packages/CraCore/Tests/CraCoreTests/LibraryRailIconsTests.swift @@ -111,6 +111,18 @@ import Testing #expect(T.tooltipDelay == 0.45) } + /// Arc 1.170's foot (AX frames): the back arrow 32 x 32 pt at x 8, 8 pt above the bottom, and the gift button at + /// x 73 on its row, 8 pt in from the 113 pt rail's right edge. + @Test func theGiftButtonSitsRightOfTheBackArrowAsArcs() { + typealias T = LibraryRailTile + #expect(T.backFrame(railHeight: 1000) == CGRect(x: 8, y: 960, width: 32, height: 32)) + #expect(T.giftFrame(railHeight: 1000) == CGRect(x: 73, y: 960, width: 32, height: 32)) + // A short window moves the row with the bottom, and the gift stays clear of the arrow and inside the rail. + let back = T.backFrame(railHeight: 300), gift = T.giftFrame(railHeight: 300) + #expect(gift.minY == back.minY && gift.minX > back.maxX) + #expect(gift.maxX + 8 == CGFloat(LibraryWidth.rail)) + } + /// The icon's lines are the palette's maxContrastColor and its insides the cutoutColor: on a dark /// sidebar the theme's light tint over its darkest shade, on a light one the other way round. @Test func iconColoursAreTheThemesTwo() { diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift index 0aa4faac3..e0e97e4f4 100644 --- a/Sources/Cra/App/AppDelegate.swift +++ b/Sources/Cra/App/AppDelegate.swift @@ -2009,6 +2009,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation { CraLog.note("library back arrow: \(pressed ? "pressed" : "no library")") return } + // libraryGift=1: the Library rail's gift button, as its click sends it; cra.log says its glyph, tip and + // place beside the back arrow, and "share cra sheet:" whether the sheet opened on the window. + if dict["libraryGift"] != nil { + let readout = (main.shell.sidebarHost as? SidebarView)?.debugLibraryGift() + CraLog.note("library gift: \(readout.map { "pressed \($0)" } ?? "no library")") + return + } if let name = dict["libraryRail"] { guard let page = LibraryPage(rawValue: name), let sidebar = main.shell.sidebarHost as? SidebarView else { CraLog.note("library rail: none"); return diff --git a/Sources/Cra/UI/Settings/MemberCardView.swift b/Sources/Cra/UI/Settings/MemberCardView.swift index da19cfc16..e4fe58d0e 100644 --- a/Sources/Cra/UI/Settings/MemberCardView.swift +++ b/Sources/Cra/UI/Settings/MemberCardView.swift @@ -320,6 +320,9 @@ private struct ShareCraCard: View { struct ShareCraSheet: View { @Environment(\.dismiss) private var dismiss @State private var copied = false + /// Set when AppKit hangs the sheet on a browser window (the Library's gift button): SwiftUI's dismiss closes only + /// what SwiftUI presented, as Settings' sheet is. + var close: (() -> Void)? private static let background = Color(.sRGB, red: 0.11, green: 0.11, blue: 0.12) private static let ticket = Color(.sRGB, red: 0.13, green: 0.19, blue: 0.2) @@ -329,7 +332,7 @@ struct ShareCraSheet: View { VStack(spacing: 0) { HStack { Spacer() - Button { dismiss() } label: { + Button { if let close { close() } else { dismiss() } } label: { Image(systemName: "xmark").font(.system(size: 15, weight: .medium)).foregroundStyle(.white.opacity(0.8)) } .buttonStyle(.plain) diff --git a/Sources/Cra/UI/Sidebar/LibraryView.swift b/Sources/Cra/UI/Sidebar/LibraryView.swift index 93cfec1d4..26315d6cb 100644 --- a/Sources/Cra/UI/Sidebar/LibraryView.swift +++ b/Sources/Cra/UI/Sidebar/LibraryView.swift @@ -12,7 +12,8 @@ import UniformTypeIdentifiers /// - The list column: a 36 pt search field ("Search Archive…") from x 120 and a Filter button /// at the top, 10 pt from the window top; day headers ("Today", 13 pt semibold); rows 56 pt /// apart with a 24 pt icon at x 130, the title at x 164 (14 pt) and the URL under it (12 pt). -/// - A back arrow (32×32 at x 8, 8 pt above the bottom) leaves the Library. +/// - A back arrow (32×32 at x 8, 8 pt above the bottom) leaves the Library; a gift button at x 73 on its row opens +/// "Share Arc with a friend", Cra's Share Cra with a Friend (LibraryRailTile.giftFrame). /// - Arc leaves it by the shortcut, Escape, that arrow or a swipe (LibraryCloseSource), never by /// clicking elsewhere, and reopens it on the page last shown. /// - Opening takes 2–3 frames (the Library slides in from a little to the left); closing slides @@ -49,6 +50,7 @@ final class LibraryView: NSView { super.init(frame: .zero) rail.onPick = { actions.showLibrary($0) } rail.onBack = { actions.closeLibrary() } + rail.onGift = { actions.shareCra() } rail.pageMenu = { [store, weak self] p in LibraryListView.pageMenu(p, store: store, profile: (self?.window?.windowController as? MainWindowController)?.profileDirectoryName) } list.onEscape = { actions.closeLibrary() } addSubview(rail) @@ -69,6 +71,9 @@ final class LibraryView: NSView { /// Scenarios (#726): the rail's back arrow, as its click sends it. func debugBack() { rail.onBack() } + /// Scenarios: the rail's gift button, as its click sends it; its glyph, tip and place beside the back arrow's. + func debugGift() -> String { rail.pressGift() } + /// Scenarios (#649): see LibraryListView.debugDownloadMore. func debugDownloadMore() -> String { list.debugDownloadMore() } @@ -141,12 +146,13 @@ final class LibraryView: NSView { } /// The rail: a faint wash brightening to the right, ending in a hairline; the page buttons -/// centred; the back arrow at the bottom. +/// centred; the back arrow and the gift button at the bottom. private final class LibraryRailView: NSView { var onPick: (LibraryPage) -> Void = { _ in } /// Arc's "Show media" folders, on a right-click of the Media button. var pageMenu: (LibraryPage) -> NSMenu? = { _ in nil } var onBack: () -> Void = {} + var onGift: () -> Void = {} var colors = SidebarColors() { didSet { refresh() } } /// The icons' two colours, from the space's theme: their lines, and what fills the shown page's. var tones: (lines: NSColor, inside: NSColor) = (.white, .black) { didSet { refresh() } } @@ -154,6 +160,7 @@ private final class LibraryRailView: NSView { private let hairline = CALayer() private var buttons: [LibraryRailButton] = [] private var back: SidebarGlyphButton? + private var gift: SidebarGlyphButton? private var page: LibraryPage = .downloads let pages: [LibraryPage] /// The panel's reach back past the rail's leading edge (LibraryView.railStretch). @@ -221,15 +228,32 @@ private final class LibraryRailView: NSView { addSubview(b) back = b } + if gift == nil { + // Arc's gift beside its back arrow, drawn as that arrow is. + let b = SidebarGlyphButton(symbol: "gift", size: 32, height: 32, iconSize: 15, weight: .regular, + help: "Share Cra with a friend", colors: colors) { [weak self] in self?.onGift() } + addSubview(b) + gift = b + } back?.colors = colors + gift?.colors = colors needsLayout = true } + /// cra://debug?libraryGift: the gift button's click, and what it is and where, beside the back arrow. + func pressGift() -> String { + guard let gift, let back else { return "none" } + func place(_ f: NSRect) -> String { "\(Int(f.minX)),\(Int(f.minY)) \(Int(f.width))x\(Int(f.height))" } + let readout = "\(gift.debugReadout) at \(place(gift.frame)), back arrow at \(place(back.frame))" + gift.action() + return readout + } + override func layout() { super.layout() let w = LibraryMetrics.rail - 1, h = bounds.height placeWash() - // Spacer(minLength: title area), the buttons 20 apart, Spacer, the back arrow 8 pt in. + // Spacer(minLength: title area), the buttons 20 apart, Spacer, the back arrow and the gift 8 pt in. // The tiles between the title area and the back arrow; a short window shrinks them and drops their labels. let column = LibraryRailTile.column(count: buttons.count, height: h, topInset: CraMetrics.titleAreaHeight, bottomInset: 40) let width = LibraryRailTile.size.width @@ -237,7 +261,8 @@ private final class LibraryRailView: NSView { b.showsLabel = column.showsLabel b.frame = NSRect(x: (w - width) / 2, y: column.top + CGFloat(i) * column.slot, width: width, height: column.tileHeight) } - back?.frame = NSRect(x: 8, y: h - 8 - 32, width: 32, height: 32) + back?.frame = LibraryRailTile.backFrame(railHeight: h) + gift?.frame = LibraryRailTile.giftFrame(railHeight: h) } } diff --git a/Sources/Cra/UI/Sidebar/List/SidebarView.swift b/Sources/Cra/UI/Sidebar/List/SidebarView.swift index 8ec8d17bb..8159e38fb 100644 --- a/Sources/Cra/UI/Sidebar/List/SidebarView.swift +++ b/Sources/Cra/UI/Sidebar/List/SidebarView.swift @@ -102,6 +102,8 @@ final class SidebarView: NSView { libraryHost.debugBack() return true } + /// The Library rail's gift button, pressed (see LibraryView.debugGift); nil with no Library up. + func debugLibraryGift() -> String? { libraryHost?.debugGift() } /// Arc's Create a Space page, over the space's column while one is being made. private var creationHost: SpaceCreationView? var debugSpaceCreation: String { creationHost?.debugLine ?? "none" } diff --git a/Sources/Cra/UI/SidebarUIState.swift b/Sources/Cra/UI/SidebarUIState.swift index 66289fed9..c3a62ab4e 100644 --- a/Sources/Cra/UI/SidebarUIState.swift +++ b/Sources/Cra/UI/SidebarUIState.swift @@ -266,6 +266,8 @@ final class SidebarActions { /// The Library in the sidebar: open it on a page, leave it, restore an archived tab from it. var showLibrary: (LibraryPage) -> Void = { _ in } var closeLibrary: () -> Void = {} + /// The Library's gift button: Share Cra with a Friend, as a sheet on this window. + var shareCra: () -> Void = {} var restoreArchived: (UUID) -> Void = { _ in } var resetPinnedTab: (UUID) -> Void = { _ in } /// Arc's "Share this tab instead" on a row (TabSharing): the call shares that tab, which shows. diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift index 12897c998..c0f672251 100644 --- a/Sources/Cra/UI/Windows/MainWindowController.swift +++ b/Sources/Cra/UI/Windows/MainWindowController.swift @@ -503,6 +503,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM sidebarActions.toggleLibrary = { [weak self] in self?.toggleLibrary() } sidebarActions.showLibrary = { [weak self] page in self?.showLibrary(page) } sidebarActions.closeLibrary = { [weak self] in self?.leaveLibrary() } + sidebarActions.shareCra = { [weak self] in self?.showShareCra() } sidebarActions.restoreArchived = { [weak self] id in guard let self else { return } _ = self.store.restoreArchived(id) @@ -3809,6 +3810,14 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM currentBrowser?.setFocused(true) } + /// The Library's gift button (Arc's opens "Share Arc with a friend"): Settings' Share Cra with a Friend sheet, on + /// this window, with the Library left open under it. + func showShareCra() { + guard let window else { return } + let shown = DialogPanel.present(over: window) { close in ShareCraSheet(close: close) } + CraLog.note("share cra sheet: \(shown ? "opens on the window" : "not shown, a sheet is already up")") + } + /// Arc's floating sidebar lives in its own panel above the page windows (see FloatingSidebarController). private(set) var floatingSidebar: FloatingSidebarController? diff --git a/Tests/Scenarios/library-gift.scenario b/Tests/Scenarios/library-gift.scenario new file mode 100644 index 000000000..d148ef226 --- /dev/null +++ b/Tests/Scenarios/library-gift.scenario @@ -0,0 +1,25 @@ +# The Library's gift button sits right of its back arrow, as Arc's (Arc 1.170: the arrow 32×32 at x 8, 8 pt above the +# bottom, the gift at x 73), drawn as the arrow is, with the tip "Share Cra with a friend". Its click opens Settings' +# Share Cra with a Friend sheet on the browser window, as Arc's opens "Share Arc with a friend", and leaves the Library +# open under it. A second press while the sheet is up opens no second one. + +cra://action/openLibrary +wait 1.5 +cra://debug?windowState=before +expect-log window state before: main0 .* sheet=0 +cra://debug?libraryGift=1 +expect-log library gift: pressed gift "Share Cra with a friend" at 73,[0-9]+ 32x32, back arrow at 8,[0-9]+ 32x32 +expect-log share cra sheet: opens on the window +wait 1 +cra://debug?windowState=shared +expect-log window state shared: main0 .* sheet=1 +cra://debug?libraryGift=1 +expect-log share cra sheet: not shown, a sheet is already up + +# Closed as Escape would: the window has no sheet again, and the Library is still there. +cra://debug?endSheets=1 +wait 1 +cra://debug?windowState=closed +expect-log window state closed: main0 .* sheet=0 +cra://debug?libraryBack=1 +expect-log library back arrow: pressed diff --git a/docs/arc-parity.md b/docs/arc-parity.md index 08ba1d778..af859114a 100644 --- a/docs/arc-parity.md +++ b/docs/arc-parity.md @@ -53,7 +53,7 @@ or Arc-only service), per CONTRIBUTING.md. | Page zoom | View ▸ Zoom In / Zoom Out / Zoom to Actual Size (⌘+ ⌘− ⌘0): Chrome's steps (100 → 110 → 125 %), each one shown as a toast at the page's top right ("125%", "100%"), gone after about 4.9 s or a click | done | Measured in Arc 1.174.3 (26 Nov 2026): the same ShinyToast as every other toast; no lasting badge in the address bar or sidebar field. `PageZoomSteps` (CraCore), `page-zoom-toast` scenario (#856). | | Help menu | Getting Started, Release Notes, Contact the Team, Visit Help Center, Restore Data | done | Cra Help (Arc's Help Center and Getting Started guide), Release Notes, Report an Issue… (Contact the Team), Essential Keyboard Shortcuts, Troubleshooting ▸ Task Manager / Reveal Data / Copy Info. *skip*: Restore Data and Export Arc Notes (Arc's account and Notes), Record Trace (chrome://tracing is a developer tool). | | Ad blocker upsell card, Account, Sign Out, Send to Dia, Share Space | | *skip* | Account/cloud. | -| Membership card, Gift Arc to a Friend | Settings ▸ Account | done (Cra's own) | Settings' first tab, named after the user like Arc's (GitHub #372): a member card made on the Mac (macOS name, a nickname, EARLY '26, a months stamp in the first year, then anniversaries, the day Cra first ran), its share, save and copy buttons, the default-browser banner, and "Share Cra with a Friend", whose sheet copies or shares crabrowser.app tagged `utm_campaign=share`. No account, server or gift unlocks. | +| Membership card, Gift Arc to a Friend | Settings ▸ Account | done (Cra's own) | Settings' first tab, named after the user like Arc's (GitHub #372): a member card made on the Mac (macOS name, a nickname, EARLY '26, a months stamp in the first year, then anniversaries, the day Cra first ran), its share, save and copy buttons, the default-browser banner, and "Share Cra with a Friend", whose sheet copies or shares crabrowser.app tagged `utm_campaign=share`. The Library's gift button, right of its back arrow as in Arc, opens the same sheet on the browser window (scenario library-gift). No account, server or gift unlocks. | | Space icon: Emoji and Icon tabs | Space header icon, Change Space Icon… | done, plus an Image tab (Cra's own) | Arc's picker has Emoji and Icon. Cra adds Image (GitHub PR #395, Victor agreed 12 Nov 2026): a PNG, SVG or other picture, chosen or dropped, stored as a 96 px PNG in `Space.iconImage`. The dock fades it like an emoji while its space is closed. An older Cra shows the space with no icon (a dot) and drops the picture when it saves. | | Max: 5-Second Previews | Settings ▸ Max | done | Arc's hover cards on the Mac's Apple Intelligence: Arc's links on Google, X and Hacker News, or Shift on any link (the small card within the site); Arc's prompt, card, timing and share menu (arc-reverse-engineering.md). | | Max: Ask on Page | ⌘F, Settings ▸ Max | done | Arc's find-or-ask card on the Mac's Apple Intelligence (#393): typing finds, Ask asks about the page with Arc's prompt, quotes with Find on Page, "This page was long, so I read the first N%." (arc-reverse-engineering.md). | diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md index ae4f29b48..bba9b8de3 100644 --- a/docs/arc-reverse-engineering.md +++ b/docs/arc-reverse-engineering.md @@ -2748,6 +2748,8 @@ Library button's hover list (downloads) and its click (the archive) showed diffe leave. Opening it from a hidden sidebar shows the sidebar until it closes. Unlike Arc's quick slide-and-fade, the button and ⇧⌘L slide the Library in and out on the swipe's spring when the sidebar is docked (Victor, 2 Nov 2026; see "Swiping into the Library" below); a second press mid-slide turns it around at its current speed. + The gift button at x 73 (`LibraryRailTile.giftFrame`) opens Settings' Share Cra with a Friend sheet on the window + (`MainWindowController.showShareCra`, scenario library-gift). ## A tab open in two windows (Arc 1.170, 27 Oct 2026, Swift metadata)