Skip to content

Latest commit

 

History

History
142 lines (111 loc) · 5.98 KB

foundation.md

File metadata and controls

142 lines (111 loc) · 5.98 KB

Foundation

Design tokens and primitives shared by every component. Files live in Sources/DashUIKit/Foundation/.


Colors

Color+DashUI.swift — file Foundation/Color+DashUI.swift

All theme colors are exposed through the Color.dash namespace (DashColors enum). Each property maps to a named color set in the asset catalog (Media.xcassets/Colors/…), so light/dark variants come from the assets — never hardcode hex.

Text("Hi")
    .foregroundStyle(Color.dash.primaryText)
    .background(Color.dash.secondaryBackground)

Token groups (see the source for the full list):

  • Text: primaryText, secondaryText, tertiaryText, whiteText, blueText, successText, errorText
  • Background: primaryBackground, secondaryBackground, tertiaryBackground, blueBackground
  • Buttons: buttonFilledBlue…, buttonFilledRed…, buttonTintedBlue/Red/Gray/White…, buttonStrokeGray…, buttonPlainBlue/Black/Red/White…, buttonFilledWhite… (each has …Background, …BackgroundDisabled, …Content, …ContentDisabled where applicable). These back DashButtonStyle.
  • Component-specific: grabberFill, searchBackground/searchIcon/…, segmentControl…, select…, stepper…, switchTrackFillOn/Off…, textFieldCryptoAddress…, textFieldPlaceholder, toastBackground/toastText, toolbar…, topIntro…, bottomNavBackground, navBackButton, backgroundOverlay, listGiftCardNumberBackground, badgeBackground…, statusBarElements, shortcutBarBackground
  • Raw tokens: blue (+ blueAlpha5…90), black/black1000Alpha5…90/black800/900, gray50…500 (+ alpha variants), green/greenAlpha10, red/redAlpha5/10, white/whiteAlpha5…90, orange, yellow, lightBlue, purple, topper, uphold
  • shadow — the Shadow colorset (subtle on light, clear on dark); used by MenuViewModifier.

Adding a color: add the color set to the catalog, then add a matching static var … { dashAsset("AssetName") } line. Do not introduce inline Color(hex:).


Typography

Files Foundation/DashTextStyle.swift, Font+DashUI.swift, LineHeight+DashUI.swift.

Two layers:

  • Font.dash.* (DashFonts) — plain Font tokens (size + weight only).
  • DashTextStyle — pairs a font token with its design line height. Apply both at once with the .dashFont(_:) view modifier.
Text(body).dashFont(.subhead)        // font (15 regular) + line height 20
Text(label).font(Font.dash.footnote) // just the font, when line height doesn't matter

Available styles (size / weight / line height), each present as both Font.dash.X and DashTextStyle.X:

Style Size Weight Line height
largeTitle 34 bold 41
title1 28 bold 34
title2 22 bold 28
title3 20 bold 25
title3Medium 20 medium 25
headline 17 bold 22
body 17 regular 22
callout 16 regular 21
calloutMedium 16 semibold 21
subhead 15 regular 20
subheadMedium 15 medium 20
footnote 13 regular 18
footnoteMedium 13 medium 18
caption1 12 regular 16
caption1Medium 12 medium 16
caption2 11 regular 13

.dashLineHeight(size:lineHeight:) (in LineHeight+DashUI.swift) is the lower-level modifier .dashFont uses — it adds the leading that fixed-size system fonts otherwise lack, keeping single lines vertically centered. Use .dashFont in normal code.


Icons

File Foundation/Image+DashUI.swift.

DashIconSource abstracts where an icon comes from; render any source with Image(dash:), then apply your own .resizable(), sizing, and color.

public enum DashIconSource {
    case system(_ name: String)                       // SF Symbol
    case custom(_ name: String, bundle: Bundle? = nil) // asset-catalog image
    case uiImage(_ image: UIImage)                     // runtime UIImage
}

Image(dash: .system("info.circle"))
Image(dash: DashIcon.Menu.send.source)
    .resizable().scaledToFit().frame(width: 30, height: 30)

Every bundled image is a case of a DashIcon group (Foundation/Icon_DashUI.swift), whose raw value is the imageset name: DashIcon.Menu.send.source is the DashIconSource, .image the plain Image. Inside the library, use these cases rather than .custom(name, bundle:); CI rejects a package-bundle lookup whose name is not one literal.

Many components accept a DashIconSource? directly (DashButton.leadingIcon, MenuItem.leadingIcon, RadioButtonRow.icon, …).

Bundled custom assets (under Media.xcassets/Icons & Illustrations/) include nav icons (navigationbar-back/close/plus/info), search icons, currency glyphs (icon_dash_currency, enter-amount-dash, chevron-down-currency-select), checkbox icons, text-field icons (text-field-qr, text-field-scan-qr, text-field-clear), menu icons (menu-send/receive, support, …), explainer-sheet feature icons (feature-shield, feature-timer, feature-identity, feature-platform, each with a -purple variant where one exists), segmented-control arrows (segmented-control-receive/transfer/send, each with a grey -disabled twin for the unselected segment), system-message icons (system-message-info-rect-small, system-message-public, system-message-shield-small, system-message-timer-small, system-message-unmixed-funds, system-message-username-change, system-message-warning-triangle), the vote thumb (voting-thumb-up), the list filter glyph (filter-s), and illustrations (illustration-dash-dex, illustration-xmark, checkmark, crowdnode.warning).


Bundle

File Foundation/BundleToken.swift.

Bundle.dashUIKit is a convenience alias for Bundle.module, used when loading custom assets from the package bundle. For a bundled icon, DashIcon already does this with a compile-checked name: DashIcon.Menu.send.image rather than Image("menu-send", bundle: .dashUIKit).