Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Constant values that can be reused in the stylesheet #24

Merged
merged 4 commits into from
Jun 23, 2019

Conversation

lucaslt89
Copy link
Contributor

@lucaslt89 lucaslt89 commented Jun 8, 2019

  • Migrated to Swift 5. Made StyleableComponents a public header
  • Added support for constant values in the JSON file defined in a new object at the same level of the styles object
    "constants": {
        "PrimaryColor" : "#FF5A5F",
        "Header5Font" : {
            "name": "CircularStd-Bold",
            "size": 18.0
        }
    }

That can be later reused in the styles dictionary as following:

        {
            "styleName": "Primary",
            "styleProperties": {
                "backgroundColor": "$PrimaryColor"
            }
        },
        {
            "styleName": "Header5",
            "styleProperties": {
                "font": "$Header5Font",
                "textColor": "#3f444c"
            }
        }

Copy link
Owner

@daniel-hall daniel-hall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucaslt89 This is a great addition — thanks for the PR! Only two requests:

  1. See other comment inline — I'm concerned about breaking existing stylesheet json files with the change and a solution to avoid that (for example, making the constants dictionary optional) would be needed.

  2. How about updating the StylishExample project in this repo so the example of the stylesheet.json uses a constant as supported by your addition, perhaps for a color since there are some duplicates in there IIRC?

Thanks again for proposing this useful addition!

Stylish/JSONStylesheet.swift Outdated Show resolved Hide resolved
Copy link
Owner

@daniel-hall daniel-hall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! Glad to have this new feature!

@daniel-hall daniel-hall merged commit e621654 into daniel-hall:master Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants