Easily extend any project to include an intelligent design component browser.
Y—Component Browser is licensed under the Apache 2.0 license.
Documentation is automatically generated from source code comments and rendered as a static website hosted via GitHub Pages at: https://yml-org.github.io/YComponentBrowser/
A category is a collection of components that share common traits. A category may contain subcategories. By default, components are laid out in nested table views, with each component being represented by a single row. A CatalogDisplayView
is used to display a component in a single row. It displays small components together with a title and optional detail description. This is used for icons, fonts, and colors, but also works well for smaller components such as buttons. By using generics, CatalogDisplayView
can display any view (populated with an associated model). The framework includes pre-defined categories for displaying common components: colors, fonts, and icons.
The catalog display view model has four parameters:
title
: titledetail
: detail description (optional), defaults to nil
axis
: primary axis for the content view, defaults to .horizontal
model
: model to populate the content viewBy using CustomCategory
, a larger component, such as a card view, can be shown. Each custom component might occupy a full row by itself.
For even larger components such as a view controller, we may skip the table view controller and display the component on a full screen by itself. This is accomplished by defining a custom category and destination that conform to the Classification
and Destination
protocols, respectively.
We can display colors by declaring a ColorCategory
object:
let category = ColorCategory(
name: "Easter",
models: [
.init(
title: "Purple",
detail: "HEX: #D9D7F1",
model: UIColor(red: 217/255, green: 215/255, blue: 241/255, alpha: 1)
),
.init(
title: "Light Yellow",
detail: "HEX: #FFFDDE",
model: UIColor(red: 1, green: 253/255, blue: 222/255, alpha: 1)
)
]
)
where you need to specify:
name
: color category namemodels
: information about the colors to be displayedWe can display fonts by declaring a FontCategory
object:
let category = FontCategory(
name: "TiemposHeadline Bold",
models: [
.init(
title: "Title 1",
model: FontView.Model(
font: UIFont(name: "TiemposHeadline-Bold", size: 36)!
)
),
.init(
title: "Title 2",
model: FontView.Model(
font: UIFont(name: "TiemposHeadline-Bold", size: 26)!
)
)
]
)
where you need to specify:
name
: font category namemodels
: information about the fonts to be displayedWe can display icons by declaring an IconCategory
object:
let category = IconCategory(
name: "Media",
models: [
.init(
title: "Play",
model: UIImage(systemName: "play.fill")!
),
.init(
title: "Pause",
model: UIImage(systemName: "pause.fill")!
)
]
)
where you need to specify:
name
: icon category namemodels
: information about the icons to be displayedWe can display nested subcategories by declaring a CatalogCategory
object:
let category = CatalogCategory(
name: "Foundational",
subcategories: [
ColorSample.category,
IconSample.category,
FontSample.category
]
)
where you need to specify:
name
: category namesubcategories
: array of subcategoriesWe can display small custom components (such as buttons) by declaring a CustomCategory
object that leverages CatalogDisplayView
:
let category = CustomCategory<CatalogDisplayView<DemoButton>>(
name: "Demo Button",
models: [
.init(
title: "Login",
model: .init(
backgroundColor: .systemBlue,
title: "Login",
titleColor: .white
)
),
.init(
title: "Logout",
model: .init(
backgroundColor: .systemRed,
cornerRadius: 25,
title: "Logout",
titleColor: .white
)
),
]
)
where you need to specify:
name
: category namemodels
: information about the components to be displayed (in this case buttons)We can display medium-sized custom components (such as a card or a note) by declaring a CustomCategory
object that directly uses the view to be displayed:
let category = CustomCategory<NoteView>(
name: "Demo View",
models: [
NoteView.Model(
title: "Grocery List",
body: "1) apples\n 2) sugar\n 3) coffee\n 4)snacks",
backgroundColor: .systemYellow
),
NoteView.Model(
title: "Todo List",
body: ""1)Buy Grocery\n 2)Prepare meal\n 3) Call a friend\n "",
backgroundColor: .systemYellow
)
]
)
where you need to specify:
name
: category namemodels
: information about the components to be displayed (in this case notes)In order to display large custom components (including full-screen views and even view controllers), we need to:
struct CarouselDestination: Destination {
let navigationTitle: String?
let presentationStyle: Presentation = .detail
func getDestinationController() -> UIViewController {
CarouselDemoViewController(navigationTitle: navigationTitle)
}
}
struct CarouselCategory: Classification {
let name: String
var destination: Destination {
CarouselDestination(navigationTitle: name)
}
}
let category = CarouselCategory(name: "Carousel Demo View Controller")
We utilize semantic versioning.
{major}.{minor}.{patch}
e.g.
1.0.5
We utilize a simplified branching strategy for our frameworks.
main
main
main
as they are completed and approved.main
gets tagged with an updated version # for each releasefeature/{ticket-number}-{short-description}
bugfix/{ticket-number}-{short-description}
e.g.
feature/CM-44-button
bugfix/CM-236-textview-color
Prior to submitting a pull request you should:
jazzy
from the command line and confirm that you have 100% documentation coverage.git rebase -i HEAD~{commit-count}
to squash your last {commit-count} commits together into functional chunks.main
) has been updated since you created your branch, use git rebase main
to rebase your branch.
When submitting a pull request:
When merging a pull request:
1.0.5
)brew install swiftlint
sudo gem install jazzy
Open Package.swift
in Xcode.
You can generate your own local set of documentation directly from the source code using the following command from Terminal:
jazzy
This generates a set of documentation under /docs
. The default configuration is set in the default config file .jazzy.yaml
file.
To view additional documentation options type:
jazzy --help
A GitHub Action automatically runs each time a commit is pushed to main
that runs Jazzy to generate the documentation for our GitHub page at: https://yml-org.github.io/YComponentBrowser/
link |
Stars: 5 |
Last commit: 4 days ago |
Add Swift Package Index integration
Full Changelog: https://github.com/yml-org/YComponentBrowser/compare/1.0.0...1.0.1
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics