|
1 | 1 | # FatSidebar
|
2 |
| -Custom vertical button toolbar for macOS |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +[](https://github.com/Carthage/Carthage) |
| 8 | + |
| 9 | +Custom vertical button toolbar for macOS. |
| 10 | + |
| 11 | +## Item Styles |
| 12 | + |
| 13 | +The component supports 2 different styles: `.regular` and `.small`. |
| 14 | + |
| 15 | +At the moment, `FatSidebar` [does not support responsive switching between styles](https://github.com/CleanCocoa/FatSidebar/issues/1). If you decide to display the sidebar at 50pt width or more, the `.regular` style is a good match. |
| 16 | + |
| 17 | +### Regular Style |
| 18 | + |
| 19 | +The `.regular` style displays the button label right below the icon: |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +### Small Style |
| 24 | + |
| 25 | +The `.small` style doesn't show the label by default. But when you hover over an item, it expands horizontally to show the label. |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +This is a good choice for super-long labels that don't fit the regular style. |
| 30 | + |
| 31 | +If you configure the sidebar to be fairly wide, it still works as expected -- but obviously is a lot more spacious. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +## Theming |
| 37 | + |
| 38 | +The component's colors can be changed by creating a custom `FatSidebarTheme` implementation: |
| 39 | + |
| 40 | +```swift |
| 41 | +public protocol FatSidebarTheme { |
| 42 | + var itemStyle: FatSidebarItemStyle { get } |
| 43 | + var sidebarBackground: NSColor { get } |
| 44 | +} |
| 45 | + |
| 46 | +public protocol FatSidebarItemStyle { |
| 47 | + var background: StatefulColor { get } |
| 48 | + var borders: Borders { get } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +`StatefulColor` boils down to a struct with three `NSColor` values for the three states a `FatSidebarItem` can be in: `normal`, `selected`, and `highlighted`. It comes with a convenience initializer in case you don't like when things change in your life: `StatefulColor.init(single:)` |
| 53 | + |
| 54 | +`Borders` is a struct with 4 optional `StatefulColor` objects, one for each side of the item. |
| 55 | + |
| 56 | +### Example Theme |
| 57 | + |
| 58 | +As a hat-tip to the OmniGroup's good-looking sidebar from OmniFocus, here's a theme that's close to OmniFocus's colors: |
| 59 | + |
| 60 | +```swift |
| 61 | +struct OmniFocusTheme: FatSidebarTheme { |
| 62 | + |
| 63 | + let itemStyle: FatSidebarItemStyle = OmniFocusItemStyle() |
| 64 | + let sidebarBackground = OmniFocusTheme.backgroundColor |
| 65 | + |
| 66 | + static var selectedColor: NSColor { return #colorLiteral(red: 0.901724875, green: 0.9334430099, blue: 0.9331719875, alpha: 1) } |
| 67 | + static var recessedColor: NSColor { return #colorLiteral(red: 0.682291925, green: 0.6823920608, blue: 0.68227005, alpha: 1) } |
| 68 | + static var backgroundColor: NSColor { return #colorLiteral(red: 0.7919496894, green: 0.8197044134, blue: 0.8194655776, alpha: 1) } |
| 69 | + |
| 70 | + struct OmniFocusItemStyle: FatSidebarItemStyle { |
| 71 | + |
| 72 | + let background = StatefulColor( |
| 73 | + normal: OmniFocusTheme.backgroundColor, |
| 74 | + selected: OmniFocusTheme.selectedColor, |
| 75 | + highlighted: OmniFocusTheme.recessedColor) |
| 76 | + |
| 77 | + let borders = Borders( |
| 78 | + bottom: StatefulColor(single: OmniFocusTheme.recessedColor), |
| 79 | + right: StatefulColor( |
| 80 | + normal: OmniFocusTheme.recessedColor, |
| 81 | + selected: OmniFocusTheme.selectedColor, |
| 82 | + highlighted: OmniFocusTheme.recessedColor)) |
| 83 | + } |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +## Code License |
| 88 | + |
| 89 | +Copyright (c) 2017 Christian Tietze. Distributed under the MIT License. |
| 90 | + |
| 91 | +## Icon License |
| 92 | + |
| 93 | +Iconic v1.9.0 License. To view Iconic's license, please go to <https://useiconic.com/license/>. |
0 commit comments