|
1 | 1 | # CodeEditSymbols |
2 | 2 |
|
3 | | -A description of this package. |
| 3 | +A package containing all custom assets for CodeEdit. These are mostly custom [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/#creating-custom-symbols). |
| 4 | + |
| 5 | +## How to use |
| 6 | + |
| 7 | +### `NSImage`: |
| 8 | + |
| 9 | +```swift |
| 10 | +import CodeEditSymbols |
| 11 | + |
| 12 | +let nsImage = NSImage.symbol(named: "name_of_the_symbol") |
| 13 | +``` |
| 14 | + |
| 15 | +### `Image`: |
| 16 | + |
| 17 | +```swift |
| 18 | +import CodeEditSymbols |
| 19 | + |
| 20 | +let image = Image(symbol: "name_of_the_symbol") |
| 21 | +``` |
| 22 | + |
| 23 | +## Creating a new Asset |
| 24 | + |
| 25 | +To create a new asset, follow the guide on [Apple's developer website](https://developer.apple.com/documentation/uikit/uiimage/creating_custom_symbol_images_for_your_app). |
| 26 | + |
| 27 | +Add the `.svg` you exported from `SF Symbols.app` to the `Symbols.xcassets` catalog. |
| 28 | + |
| 29 | +> **Important:** Make sure your symbol looks great in every font weight. |
| 30 | +
|
| 31 | +## Tests |
| 32 | + |
| 33 | +Also include snapshot tests for each symbol for `Image` as well as `NSImage`: |
| 34 | + |
| 35 | +### `NSImage`: |
| 36 | + |
| 37 | +```swift |
| 38 | +// MARK: YOUR_SYMBOL_NAME |
| 39 | + |
| 40 | +func testCreateNSImageYourSymbolName() { |
| 41 | + let image = NSImage.symbol(named: "your_symbol_name") |
| 42 | + let view = NSImageView(image: image) |
| 43 | + assertSnapshot(matching: view, as: .image) |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +### `Image`: |
| 48 | + |
| 49 | +```swift |
| 50 | +// MARK: YOUR_SYMBOL_NAME |
| 51 | + |
| 52 | +func testCreateImageYourSymbolName() { |
| 53 | + let image = Image(symbol: "your_symbol_name") |
| 54 | + let view: NSView = NSHostingController(rootView: image).view |
| 55 | + assertSnapshot(matching: view, as: .image(size: view.intrinsicContentSize)) |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +## Variants |
| 60 | + |
| 61 | +Keep different variants of a symbol in the same parent folder and name them appropriately (see Apple's own symbols for reference). |
| 62 | + |
| 63 | +You might have a symbol called `lock` and one where the symbol is inside a square where you would call that file `lock.square`. Also keep in mind to also provide a `.fill` variant if appropriate (`lock.fill`, `lock.square.fill`) |
| 64 | + |
| 65 | +### Example of a `.fill` Variant |
| 66 | + |
| 67 | +<img width="256" alt="Screen Shot 2022-04-18 at 00 29 57" src="https://user-images.githubusercontent.com/9460130/163734754-9eff9671-bb19-46de-92b0-c4c0de27c23b.png"> |
| 68 | + |
| 69 | +## Annotate the Symbol |
| 70 | + |
| 71 | +As of version 3 of `SF Symbols` it is possible to create `multi-color`, `hierarchical` and `palette` annotations inside the `SF Symbols.app`. Be sure to annotate it accordingly if appropriate. |
| 72 | + |
| 73 | +<img width="266" alt="Screen Shot 2022-04-18 at 00 40 26" src="https://user-images.githubusercontent.com/9460130/163734926-d4da422a-d7f0-4b93-a05b-3d1700c1b97c.png"> |
0 commit comments