{"id":21995667,"url":"https://github.com/alexdrone/yas","last_synced_at":"2025-08-12T01:08:47.623Z","repository":{"id":147419900,"uuid":"171849084","full_name":"alexdrone/YAS","owner":"alexdrone","description":"Yet Another Stylesheet (YAML-based Stylesheet Engine)","archived":false,"fork":false,"pushed_at":"2019-04-22T14:07:12.000Z","size":115714,"stargazers_count":26,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T17:41:30.647Z","etag":null,"topics":["stylesheet","swift","yaml"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexdrone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-02-21T10:15:34.000Z","updated_at":"2024-09-12T23:14:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"d7a19ed4-2a26-4efc-8c58-f469d43e58a1","html_url":"https://github.com/alexdrone/YAS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alexdrone/YAS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdrone%2FYAS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdrone%2FYAS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdrone%2FYAS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdrone%2FYAS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexdrone","download_url":"https://codeload.github.com/alexdrone/YAS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdrone%2FYAS/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269982069,"owners_count":24507303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["stylesheet","swift","yaml"],"created_at":"2024-11-29T21:18:04.838Z","updated_at":"2025-08-12T01:08:47.607Z","avatar_url":"https://github.com/alexdrone.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YAS [![Swift](https://img.shields.io/badge/swift-5-orange.svg?style=flat)](#) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)\n\n\u003cimg src=\"docs/logo.png\" width=150 alt=\"Logo\" align=right /\u003e\n\n**YAS** is a YAML-based stylesheet engine written in Swift.\n\n### Installing the framework\n\n```bash\ncd {PROJECT_ROOT_DIRECTORY}\ncurl \"https://raw.githubusercontent.com/alexdrone/YAS/master/bin/dist.zip\" \u003e dist.zip \u0026\u0026 unzip dist.zip \u0026\u0026 rm dist.zip;\n```\n\nDrag `YAS.framework` in your project and add it as an embedded binary.\n\nIf you are using [xcodegen](https://github.com/yonaskolb/XcodeGen) add the framework to your *project.yml* like so:\n\n```yaml\ntargets:\n  YOUR_APP_TARGET:\n    ...\n    dependencies:\n      - framework: PATH/TO/YOUR/DEPS/YAS.framework\n```\n\nIf you are using **Carthage**:\nAdd the following line to your `Cartfile`:\n\n```ruby\ngithub \"alexdrone/YAS\" \"master\"    \n```\n\n### Getting Started\n\nCreate a new YAML stylesheet and save it in a file named `style.yaml`.\n\n```yaml\nFooStyle:\n  backgroundColor: {_type: color, hex: ff0000}\n  margin: 10.0\n```\n\nLoad it up and access to its member using the built-in dynamic lookup proxy.\n\n```swift\ntry! StylesheetContext.manager.load(\"style.yaml\")\nlet margin = StylesheetContext.lookup.FooStyle.margin.cgFloat //10.0\nlet backgroundColor = StylesheetContext.lookup.FooStyle.backgroundColor.color //UIColor(...)\n```\n\nor automatically apply the style to your `UIView`:\n\n```swift\nview.apply(style: Yas.lookup.FooStyle)\n```\n\n### Built-in types\n\n```yaml\nExample:\n  cgFloat: 42.0\n  bool: true\n  integer: 42\n  # Symbols can be exported by calling ConstExpr.export([:])\n  enum: ${NSTextAlignment.right}\n  # ${...} is the expression delimiter\n  cgFloatExpression: ${41+1}\n  boolExpression: ${1 == 1 \u0026\u0026 true}\n  integerExpression: ${41+1}\n  # Custom objects.\n  # Use the reserved _type attribute to distinguish the object type.\n  # New object types can be exported by calling ObjectExpr.export(...)\n  # {_type: color, hex: ffffff, (darken: [0-100]), (lighten: [0-100]), (alpha: [0-1])}\n  color: {_type: color, hex: ff0000}\n  # {_type: font, (name: [fontname]), size: [size], (weight: [light...])}\n  font:  {_type: font, name: Arial, size: 42}\n  fontWeight: {_type: font, weight: bold, size: 12}\n  # {_type: animator, duration: 1, (curve: [easeIn...]), (damping: [0-1])}\n  animator: {_type: animator, curve: easeIn, duration: 1}\n  # {_type: text,  (name: [fontname]), size: [size], (weight: [light...]), (kern: [0..n]), (hex: [hex colorcode]), (supportDynamicType: [bool])}\n  textStyle: {_type: text, name: Arial, size: 42, kern: 2, hex: ff0000}\n```\n\n### References and anchors\n\nBy using YAML anchors and references you can reuse values across your stylesheet:\n\n```yaml\nFoo:\n  fooValue: \u0026_fooValue 42.0\nBar:\n  bar: *_fooValue\n  baz: 2\n```\n\nYou can also copy the whole style using the YAML extension construct:\n\n```yaml\nFoo: \u0026_Foo\n  aValue: 42.0\n  anotherValue: \"Hello\"\n  someColor: {_type: color, hex: ff0000}\nBar:\n  \u003c\u003c: *_Foo\n  yetAnotherValue: 2\n```\n\n#### Real life example\n\n```yaml\nPalette:\n  primaryColorHex: \u0026_primaryColorHex ff0000\n  primaryColor: \u0026_primaryColor {_type: color, hex: *_primaryColorHex}\n  primaryColor600: \u0026_primaryColor600 {_type: color, hex: *_primaryColorHex, darken: 10}\n  primaryColor700: \u0026_primaryColor700 {_type: color, hex: *_primaryColorHex, darken: 20}\nTypography:\n  primaryFontName: \u0026_primaryFontName \"Open Sans\"\n  secondaryFontName: \u0026_secondaryFontName \"Rubik\"\n  body1: \u0026_body1 {_type: attributedString, name: *_secondaryFontName, size: 14.26, kern: 0.25, color: *_primaryColorHex}\n  body2: \u0026_body2 {_type: attributedString, weight: medium, size: 12.22, kern: 0.5, color: *_primaryColorHex}\nLandingPage:\n  titleText: *_body1\n  backgroundColor: *_primaryColor600\n  topMargin: 12\n  shouldHideHero: ${horizontalSizeClass == compact}\n  tileSize: ${screenSize.width/2 - 8}  \n\n```\n\n### Cascade imports\n\nStylesheets can be split into smaller modules by using the `import` rule at the top of the main stylesheet file.\n\n```yaml\n\nimport: [typography.yaml, palette.yaml, buttons.yaml]\n\n```\n\n### Custom types\n\nYou can define your own custom object expressions by creating a new `ObjectExpr`\nsubclass.\n\n```swift\n\n@objc class MyCustomObjectExpression : ObjectExprBase {\n  // Your arguments must be marked with @obj and dynamic.\n  @objc dynamic var foo: Int = 0\n  @objc dynamic var bar: String = \"\"\n\n  override func eval() -\u003e Any? {\n    // Build your desired return types\n    return MyCustomObject(foo: foo, bar: bar)\n  }\n}\n```\n\nFinally register your `ObjectExpr` in the shared `ObjectExprRegistry`.\n\n```swift\nStylesheetContext.objectExpr.export(ObjectExprFactory(\n  type: MyCustomObjectExpression.self,\n  name: \"myObject\")\n```\n\nUse your custom define object expression in any stylesheet rule.\n\n```yaml\n\nMyStyle:\n  myCustomRule: {_type: myObject, foo: 42, bar: \"Hello\"}\n```\n\n### Reacting to stylesheet changes\n\n`Notification.Name.StylesheetContextDidChange` is posted whenever the stylesheet has been reloaded.\n\n### Dependencies and credits\n\nDeps forked from:\n\n* [yaml/libyaml](https://github.com/yaml/libyaml)\n* [nicklockwood/Expression](https://github.com/nicklockwood/Expression)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexdrone%2Fyas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexdrone%2Fyas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexdrone%2Fyas/lists"}