feat(sf-symbols): add disabled prop && lightweight SF Symbols utilities for TypeScript#6
Merged
sbaiahmed1 merged 2 commits intomainfrom Oct 30, 2025
Merged
Conversation
Reviewer's GuideIntroduces a lightweight SF Symbols helpers module in TypeScript with branded types, version support and validators; extends the native iOS MenuView component to accept and render an optional iosSymbol prop as UIImage; and updates the example App to showcase using asSFSymbol in menu items along with adjusted labels and styles. Sequence diagram for rendering menu items with SF Symbols in iOS MenuViewsequenceDiagram
participant JS as "JS (React Native)"
participant Native as "NativeMenuView"
participant iOS as "iOS MenuView"
participant UIKit as "UIKit"
JS->>Native: Pass menuItems with iosSymbol
Native->>iOS: Update props with menuItems
iOS->>UIKit: Create UIImage from iosSymbol
UIKit-->>iOS: Return UIImage
iOS->>Native: Render menu with icon
Native-->>JS: Display menu with SF Symbol icon
Class diagram for new SF Symbols utilities and MenuItem changesclassDiagram
class SFSymbol {
<<type>>
+string (branded)
}
class SFSymbolVersion {
<<type>>
+"1.0" | "1.1" | "2.0" | "2.1" | "2.2" | "3.0" | "3.1" | "3.2" | "3.3" | "4.0" | "4.1" | "4.2" | "5.0" | "5.1" | "5.2" | "5.3" | "6.0"
}
class SFSymbolsVersionSupport {
+ios: string
+macos: string
+tvos: string
+visionos: string
+watchos: string
}
class MenuItem {
+identifier: string
+title: string
+iosSymbol: string
}
class sf_symbols_ts {
+isLikelySFSymbol(name: string): boolean
+asSFSymbol(name: string): SFSymbol
+CommonSFSymbols: string[]
}
SFSymbolsVersionSupport <|-- SFSymbolVersion
sf_symbols_ts ..> SFSymbol
sf_symbols_ts ..> SFSymbolVersion
MenuItem o-- SFSymbol
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/sf-symbols.ts:156-164` </location>
<code_context>
+ * Accepts dot-separated lowercase tokens with numbers (e.g. "arrow.up.circle.fill").
+ * This is not exhaustive, but helps catch obvious mistakes without enumerating names.
+ */
+export function isLikelySFSymbol(name: string): boolean {
+ if (name.length < 2 || name.length > 128) return false;
+ return /^[a-z0-9]+(?:\.[a-z0-9]+)*$/.test(name);
</code_context>
<issue_to_address>
**suggestion:** The SF Symbol validator may reject valid symbol names with uppercase or underscores.
The current regex excludes valid SF Symbol names containing uppercase letters or underscores. Please update the regex to accommodate these cases or clarify this limitation in the documentation.
```suggestion
/**
* Heuristic validator for SF Symbol names.
* Accepts dot-separated tokens with letters (uppercase and lowercase), numbers, and underscores (e.g. "arrow.up.circle.fill", "Arrow_Up.Circle.Fill").
* This is not exhaustive, but helps catch obvious mistakes without enumerating names.
*/
export function isLikelySFSymbol(name: string): boolean {
if (name.length < 2 || name.length > 128) return false;
return /^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/.test(name);
}
```
</issue_to_address>
### Comment 2
<location> `src/sf-symbols.ts:170-178` </location>
<code_context>
if (__DEV__) {
if (!isLikelySFSymbol(name)) {
// non-throwing hint; consumers can choose to throw if they prefer
console.warn(
`[menu] Provided iosSymbol "${name}" does not match common SF Symbol naming patterns.`
);
}
}
</code_context>
<issue_to_address>
**suggestion (code-quality):** Merge nested if conditions ([`merge-nested-ifs`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/merge-nested-ifs))
```suggestion
if (__DEV__ && !isLikelySFSymbol(name)) {
console.warn(
`[menu] Provided iosSymbol "${name}" does not match common SF Symbol naming patterns.`
);
}
```
<br/><details><summary>Explanation</summary>Reading deeply nested conditional code is confusing, since you have to keep track of which
conditions relate to which levels. We therefore strive to reduce nesting where
possible, and the situation where two `if` conditions can be combined using
`and` is an easy win.
</details>
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
562372c to
e81c971
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce branded string type, version support mapping, validators and common examples for IDE hinting. Avoids bundling full symbol list while providing type safety.
Add support for disabling menu interactions through a new
disabledprop. When disabled, the menu won't respond to touch events and will visually indicate its disabled state. This includes platform-specific implementations for both iOS and Android, along with documentation and example usage.Summary by Sourcery
Add lightweight SF Symbols utilities in TypeScript and integrate optional iosSymbol support in MenuView, updating native code and example app to showcase icon rendering and UI refinements.
New Features:
Enhancements: