-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add anatomy and component rundown to README #41
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# [WIP] Ember Freestyle [](https://travis-ci.org/chrislopresto/ember-freestyle) | ||
|
||
Ember Freestyle is an Ember addon that allows you to quickly create a living styleguide for your Ember app. | ||
Ember Freestyle is an Ember addon that allows you to quickly create a living styleguide for your Ember app. Whereas | ||
other living style guide projects showcase current CSS using dummy HTML, Ember Freestyle presents existing Ember | ||
components from your app in a dedicated living style guide. | ||
|
||
*This is a work in progress.* | ||
*This is a work in progress. Collaboration is welcomed.* | ||
|
||
## Installation | ||
|
||
|
@@ -25,6 +27,86 @@ This installation process is opinionated in order to get you going quickly. We w | |
1. Navigate to `/freestyle`. You should now see something like: | ||
 | ||
|
||
## Introduction | ||
|
||
### Anatomy of a Basic Style Guide | ||
|
||
Here is a simple style guide, where `{{loading-spinner}}` is a hypothetical component **in your application**. | ||
|
||
```hbs | ||
{{#freestyle-guide title="My Living Style Guide" subtitle="Showcasing My App's Components"}} | ||
{{#freestyle-section name="UI Elements"}} | ||
{{#freestyle-usage "loading-spinner" title="Loading Spinner"}} | ||
{{loading-spinner}} | ||
{{/freestyle-usage}} | ||
{{/freestyle-section}} | ||
{{/freestyle-guide}} | ||
``` | ||
|
||
### Components | ||
|
||
Here's a brief rundown of the components Ember Freestyle provides for adding a living style guide in your app: | ||
|
||
#### freestyle-guide | ||
|
||
The `freestyle-guide` component provides the user interface for a style guide. It includes a header section and | ||
navigation controls. | ||
|
||
#### freestyle-usage | ||
|
||
The `freestyle-usage` component is the workhorse. Wrap your application's components with a `freestyle-usage` | ||
component, being sure to provide a unique slug (positional param) as follows: | ||
|
||
```hbs | ||
{{#freestyle-usage "globally-unique-slug" title="Title To Display In Style Guide"}} | ||
{{x-foo propa="aaa" propb="bbb"}} | ||
{{/freestyle-usage}} | ||
``` | ||
|
||
The snippet above will render your app's `x-foo` component as well as a handlebars snippet demonstrating how to use it. | ||
|
||
#### freestyle-section | ||
|
||
Optionally group your `freestyle-usage`-wrapped components into sections using the `freestyle-section` component. The | ||
`freestyle-section` component registers itself in order to appear in the navigation provided by the `freestyle-guide` | ||
component. | ||
|
||
#### freestyle-subsection | ||
|
||
Optionally divide your style guide sections into subsections using the `freestyle-subsection` component. | ||
|
||
```hbs | ||
{{#freestyle-guide title="My Living Style Guide" subtitle="Showcasing My App's Components"}} | ||
{{#freestyle-section name='Visual Style' as |section|}} | ||
{{#freestyle-subsection name='Typography' section=section}} | ||
{{#freestyle-usage 'visual-style-typography-foo' title='Foo Typography'}} | ||
{{x-foo-typography}} | ||
{{/freestyle-usage}} | ||
{{/freestyle-subsection}} | ||
{{#freestyle-subsection name='Colors' section=section}} | ||
{{#freestyle-usage 'visual-style-colors-fie' title='Fie Colors'}} | ||
{{x-fie-colors}} | ||
{{/freestyle-usage}} | ||
{{/freestyle-subsection}} | ||
{{/freestyle-section}} | ||
{{/freestyle-guide}} | ||
``` | ||
|
||
The snippet above will create a style guide with one 'Visual Style' section with separate subsections for | ||
'Typography' and 'Colors'. Your app's `x-foo-typography` and `x-fie-colors` components would show up in the | ||
appropriate subsections. | ||
|
||
**NOTE:** For subsection navigation to work properly, the `freestyle-section` component must yield itself as Showcasing | ||
in the above snippet. This limitation will be removed in a forthcoming release. | ||
|
||
#### freestyle-collection + freestyle-variant | ||
|
||
Documentation coming soon... | ||
|
||
#### freestyle-note + freestyle-annotation | ||
|
||
Documentation coming soon... | ||
|
||
## Customizing the Colors in Ember Freestyle's Own UI | ||
|
||
If you wish to change things like the color of UI elements like the lines that divide the `freestyle-guide` header and body or the colors of active links, you can do so by overriding any of the following SCSS variables *before* importing the `ember-freestyle` SCSS partial in your application's SCSS: | ||
|
@@ -44,18 +126,23 @@ $FreestyleGuide-color--primary: #ff0000; | |
@import 'ember-freestyle'; | ||
``` | ||
|
||
## Working within an Addon | ||
|
||
* Generator puts scss import, template, and component in wrong place | ||
* ember-freestyle needs to be a dependency, not a devDependency | ||
* Tell the build where to search for snippets | ||
* In ember-cli-build.js: | ||
``` | ||
var app = new EmberAddon(defaults, { | ||
// ... | ||
snippetSearchPaths: ['tests/dummy/app', 'app/styles'] | ||
}); | ||
``` | ||
## Using Ember Freestyle Within an Addon | ||
|
||
When using Ember Freestyle within an addon, you will need to tell teh build where to search for code snippets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. teh typo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gah There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR this! 😄 |
||
as follows: | ||
|
||
##### ember-cli-build.js | ||
|
||
```javascript | ||
var app = new EmberAddon(defaults, { | ||
// ... | ||
snippetSearchPaths: ['tests/dummy/app', 'app/styles'] | ||
}); | ||
``` | ||
|
||
When running `ember install ember-freestyle` within an addon, the generator will attempt to put the freestyle | ||
template, controller, and scss import in the wrong place. This is a known issue... please do help fix it if you | ||
are so inclined. | ||
|
||
## Running | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you requiring
section=section
because you want to support Ember < 2.3?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just out of convenience when spiking. I'm hoping to remove this requirement using the
hash
helper.