All Projects → akane → Gaikan

akane / Gaikan

Licence: mit
Declarative view styling in Swift. Inspired by CSS modules.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Gaikan

Combine Mvvm
Sample project with Combine & UIKit framework, MVVM architecture
Stars: ✭ 132 (-5.04%)
Mutual labels:  uikit
React Pages Boilerplate
Deliver react + react-router application to gh-pages
Stars: ✭ 134 (-3.6%)
Mutual labels:  css-modules
Swiftui Visual Effects
View modifiers that wrap UIVisualEffectView, with environment integration.
Stars: ✭ 137 (-1.44%)
Mutual labels:  uikit
Paper Kit 2 Angular
Free Bootstrap 4 UI Kit for Angular 2+
Stars: ✭ 133 (-4.32%)
Mutual labels:  uikit
Bartinter
Dynamically changes status bar style depending on content behind it
Stars: ✭ 1,687 (+1113.67%)
Mutual labels:  uikit
Centroui
CentroUI is a library for building user interfaces for WebVR
Stars: ✭ 135 (-2.88%)
Mutual labels:  uikit
Multiplatform Compose
A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many compose features are not yet available.
Stars: ✭ 126 (-9.35%)
Mutual labels:  uikit
Now Ui Kit
Now UI Kit Bootstrap 4 - Designed by Invision. Coded by Creative Tim
Stars: ✭ 1,705 (+1126.62%)
Mutual labels:  uikit
Messageviewcontroller
A SlackTextViewController replacement written in Swift for the iPhone X.
Stars: ✭ 1,668 (+1100%)
Mutual labels:  uikit
React Starter Boilerplate Hmr
React starter boilerplate with React Fast Refresh, React 17 and Webpack 5
Stars: ✭ 137 (-1.44%)
Mutual labels:  css-modules
Overlap
Tiny iOS library to achieve overlap visual effect
Stars: ✭ 133 (-4.32%)
Mutual labels:  uikit
Uikitswiftdsl
Swift DSL for UIKit
Stars: ✭ 134 (-3.6%)
Mutual labels:  uikit
Drawer View
📤 Custom UI component for iOS, replication of Apple's Apple Music player and Shortcuts’ components view [Swift 5.0, iOS 12].
Stars: ✭ 136 (-2.16%)
Mutual labels:  uikit
Flamesui
A css-based web components.
Stars: ✭ 133 (-4.32%)
Mutual labels:  uikit
Bezierpath Polygons
Adds a convenience initalizer to UIBezierPath for generating n-sided regular polygon paths – with rounded corners support – in Swift!
Stars: ✭ 138 (-0.72%)
Mutual labels:  uikit
5guis
A tiny macOS app that can detect the GUI technologies used in other apps.
Stars: ✭ 130 (-6.47%)
Mutual labels:  uikit
Dev Toolkit
Universal Development Toolkit for Javascript People
Stars: ✭ 134 (-3.6%)
Mutual labels:  css-modules
Instagramactivityindicator
Activity Indicator similar to Instagram's.
Stars: ✭ 138 (-0.72%)
Mutual labels:  uikit
Ui7kit
Backport flat-style UIKit from iOS7 to iOS5+
Stars: ✭ 1,682 (+1110.07%)
Mutual labels:  uikit
Shards Ui
🎨Shards is a beautiful & modern Bootstrap 4 UI kit packed with extra templates and components.
Stars: ✭ 1,718 (+1135.97%)
Mutual labels:  uikit

Gaikan

CocoaPods Compatible Carthage compatible Build Status

Gaikan gives you powerful styling capabilities using a declarative DSL in Swift. Inspired by React: CSS in JS and CSS modules.

To style UIView(s) just give them a StyleRule object:


let myLabelStyle = StyleRule() { (inout style: StyleRule) -> () in
  style.color = UIColor.redColor()
  style.border = Border(width: 1, color: UIColor.greenColor())
  style.font = UIFont(name: "Courier", size: 24)
}

self.label.styleInline = myLabelStyle

Check out the sample to see how to well integrate Gaikan into a project.

Features

  • Apply a simple style using styleInline....
  • ... or make theming using styleClass (see below for more information).
  • You can share styles using extends method to avoid repeating yourself.
  • You can style depending on your control state (enabled, highlighted, ...).
  • You can style NSAttributedString!

Properties

Check out our page on properties to find which one to use to style your views.

Starting with 0.4, we also added VirtualView. This allow you to apply style effects on some non UIView attributes/objects:

NSObject Virtual view Description Available since
UINavigationBar titleStyle Sets title navigation bar style 0.4

Advanced usage

NSAttributedString

Just call NSAttributedString(string:"Hello", style: yourStyle) to get a styled NSAttributedString.

Alternatively you can use style.textAttributes to transform StyleRule into any NSAttributedString compatible dictionary.

Theme

Theme packages together multiple Style definitions to make a whole set.


public class SampleTheme : Theme {
  /// Non static is important if you want to reference them from InterfaceBuilder
  lazy let logo = Style(...)
  lazy let title = Style(...)
}

class CustomView: UIView {
  typealias ThemeType = RailTheme

  @IBOutlet weak var title: UILabel!
  @IBOutlet weak var footnote: UILabel!
  @IBOutlet weak var logo: UIImageView!
  @IBOutlet weak var button: UIButton!

  override func awakeFromNib() {
    self.title.styleClass = SampleTheme().logo
    self.logo.styleClass = SampleTheme().title
  }
}

You can also apply themes right from InterfaceBuilder:

Extends

You can extend your styles to reuse common features:

func primary() -> Style {
  return [
    .Color: UIColor.greenColor()
  ]
}

func large() -> Style {
  return [
    .Font: UIFont.systemFontOfSize(18)
  ]
}

func merged() -> Style {
  return Style().extends(primary(), large())
  // color: green, font: 18
}

States

You can define styles for states. They'll extend from the default state :

func style() -> Style {
  return Style() { (inout style: StyleRule) -> Void in
    style.tintColor = UIColor.whiteColor()
  }
  .state(.Selected, attributes: [
      .TintColor: UIColor.grayColor().colorWithAlphaComponent(0.6)
  ]
}

Don't hesitate to take a look at the sample to better understand how it works.

Contributing

This project was first developed by Xebia IT Architects in Paris, France. We will continue working and investing on it.

We encourage the community to contribute to the project by opening tickets and/or pull requests. Here a some of the subjects we are interested in:

  • Add UIStackView attributes (distribution, spacing, ...).
  • Support for multiple layout engines (AutoLayout, LayoutKit, Flexbox, ...)
  • Allow to define 1+ borders and corner radius. Currently defining border and radius set the 4 of them (top, bottom, left, right).
  • Better support for IBDesignable (if possible).
  • Add debugging information (style name, inheritance, ...).
  • Better integration with NSAttributedString.
  • Support for traits.
  • Anything you have in mind!

License

Gaikan is released under the MIT License. Please see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].