-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on swift implementation ( #255 ), it adds swift transforms, transformGroups, formats, and example: * flutter/class.dart format * flutter and flutter-separate transformGroups * color/hex8flutter, content/flutter/literal, asset/flutter/literal, font/flutter/literal, and size/flutter/remToDouble transforms * advanced/flutter example fixes #288 Co-authored-by: MDemetrio <[email protected]> Co-authored-by: Danny Banks <[email protected]>
- Loading branch information
1 parent
e46fbf6
commit e107c0b
Showing
16 changed files
with
407 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# style dictionary | ||
|
||
/lib/unique_file | ||
/lib/style_dictionary_color.dart | ||
/lib/style_dictionary_sizes.dart | ||
.dart_tool/ | ||
.packages | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# style_dictionary | ||
|
||
A Flutter package project to show the usage of styled-dictionary's flutter support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: style_dictionary | ||
description: A new Flutter package project. | ||
version: 0.0.1 | ||
author: | ||
homepage: | ||
|
||
environment: | ||
sdk: ">=2.1.0 <3.0.0" | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
|
||
# For information on the generic Dart part of this file, see the | ||
# following page: https://dart.dev/tools/pub/pubspec | ||
|
||
# The following section is specific to Flutter. | ||
flutter: | ||
|
||
# To add assets to your package, add an assets section, like this: | ||
# assets: | ||
# - images/a_dot_burr.jpeg | ||
# - images/a_dot_ham.jpeg | ||
# | ||
# For details regarding assets in packages, see | ||
# https://flutter.dev/assets-and-images/#from-packages | ||
# | ||
# An image asset can refer to one or more resolution-specific "variants", see | ||
# https://flutter.dev/assets-and-images/#resolution-aware. | ||
|
||
# To add custom fonts to your package, add a fonts section here, | ||
# in this "flutter" section. Each entry in this list should have a | ||
# "family" key with the font family name, and a "fonts" key with a | ||
# list giving the asset and other descriptors for the font. For | ||
# example: | ||
# fonts: | ||
# - family: Schyler | ||
# fonts: | ||
# - asset: fonts/Schyler-Regular.ttf | ||
# - asset: fonts/Schyler-Italic.ttf | ||
# style: italic | ||
# - family: Trajan Pro | ||
# fonts: | ||
# - asset: fonts/TrajanPro.ttf | ||
# - asset: fonts/TrajanPro_Bold.ttf | ||
# weight: 700 | ||
# | ||
# For details regarding fonts in packages, see | ||
# https://flutter.dev/custom-fonts/#from-packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"source": [ | ||
"properties/**/*.json" | ||
], | ||
"platforms": { | ||
"flutter": { | ||
"transformGroup": "flutter", | ||
"buildPath": "../lib/unique_file/", | ||
"files": [ | ||
{ | ||
"destination": "style_dictionary.dart", | ||
"format": "flutter/class.dart", | ||
"className": "StyleDictionary" | ||
} | ||
] | ||
}, | ||
"flutter-separate": { | ||
"transformGroup": "flutter-separate", | ||
"buildPath": "../lib/", | ||
"files": [ | ||
{ | ||
"destination": "style_dictionary_color.dart", | ||
"format": "flutter/class.dart", | ||
"className": "StyleDictionaryColor", | ||
"type": "color", | ||
"filter": { | ||
"attributes": { | ||
"category": "color" | ||
} | ||
} | ||
}, | ||
{ | ||
"destination": "style_dictionary_sizes.dart", | ||
"format": "flutter/class.dart", | ||
"className": "StyleDictionarySize", | ||
"type": "float", | ||
"filter": { | ||
"attributes": { | ||
"category": "size" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/advanced/flutter/style_dictionary/properties/color/background.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"color": { | ||
"background": { | ||
"primary": { "value": "#ffffff" }, | ||
"link": { "value": "#0366d6" }, | ||
"inverse": { "value": "#111111" } | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/advanced/flutter/style_dictionary/properties/color/core.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"color": { | ||
"core": { | ||
"white": { "value": "#ffffff" }, | ||
"black": { "value": "#111111" }, | ||
"gray": { "value": "#dddddd" }, | ||
"blue": { "value": "#0366d6" } | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/advanced/flutter/style_dictionary/properties/color/font.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"color": { | ||
"font": { | ||
"primary": { "value": "{color.core.black.value}" }, | ||
"link": { "value": "{color.core.blue.value}" }, | ||
"inverse": { "value": "{color.core.white.value}" } | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/advanced/flutter/style_dictionary/properties/size/font.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"size": { | ||
"font": { | ||
"small": { "value": 0.75 }, | ||
"medium": { "value": 1 }, | ||
"large": { "value": 1.5 } | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/advanced/flutter/style_dictionary/properties/size/padding.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"size": { | ||
"padding": { | ||
"small": { "value": 0.5 }, | ||
"medium": { "value": 1 }, | ||
"large": { "value": 2 } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<% | ||
// Licensed under the Apache License, Version 2.0 (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
// A copy of the License is located at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
%> | ||
// | ||
// <%= this.destination %> | ||
// | ||
<% | ||
// for backward compatibility we need to have the user explicitly hide it | ||
var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; | ||
if(showFileHeader) { | ||
print("// Do not edit directly\n"); | ||
print("// Generated on " + new Date().toUTCString()); | ||
} | ||
%> | ||
// | ||
<% | ||
// Filter to only those props wanted based on the filter, then sort | ||
// them by category so we keep like props together, then by name | ||
// so they are easier to find alphabetically. | ||
var props = _.sortBy(allProperties, item => item.attributes.category + item.name); | ||
%> | ||
|
||
import 'dart:ui'; | ||
|
||
class <%= this.className %> { | ||
<%= this.className %>._(); | ||
|
||
<%= _.map(props, function(prop) { return 'static const ' + prop.name + ' = ' + prop.value + ";" }).join('\n ') %> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.