Skip to content

Commit a7f335f

Browse files
add README
1 parent 793ed67 commit a7f335f

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

README.md

+92-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,93 @@
11
# FatSidebar
2-
Custom vertical button toolbar for macOS
2+
3+
![Swift 3](https://img.shields.io/badge/Swift-3.0-blue.svg?style=flat)
4+
![Version](https://img.shields.io/github/tag/CleanCocoa/FatSidebar.svg?style=flat)
5+
![License](https://img.shields.io/github/license/CleanCocoa/FatSidebar.svg?style=flat)
6+
![Platform](https://img.shields.io/badge/platform-macOS-lightgrey.svg?style=flat)
7+
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](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+
![](assets/style-regular.png)
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+
![](assets/style-small.png)
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+
![](assets/style-small_wide.png)
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/>.

assets/style-regular.png

26.8 KB
Loading

assets/style-small.png

25.3 KB
Loading

assets/style-small_wide.png

27.4 KB
Loading

0 commit comments

Comments
 (0)