Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FeatureHighlight] Split the documentation into separate articles and…
… run the readme generator. (#3620)
- Loading branch information
Showing
4 changed files
with
227 additions
and
21 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,28 @@ | ||
# Feature Highlight | ||
|
||
<div class="article__asset article__asset--screenshot"> | ||
<img src="docs/assets/feature_highlight.png" alt="Feature Highlight" width="375"> | ||
</div> | ||
|
||
The Feature Highlight component is a way to visually highlight a part of the screen in order to introduce users to new features and functionality. | ||
|
||
## Design & API documentation | ||
|
||
* [Material Design guidelines: Feature Discovery](https://material.io/guidelines/growth-communications/feature-discovery.html) | ||
|
||
<!-- toc --> | ||
|
||
- - - | ||
|
||
## Installation | ||
|
||
- [Typical installation](../../../docs/component-installation.md) | ||
|
||
## Usage | ||
|
||
- [Typical use: highlight a view](typical-use-highlight-a-view.md) | ||
|
||
## Extensions | ||
|
||
- [Color Theming](color-theming.md) | ||
- [Typography Theming](typography-theming.md) |
63 changes: 63 additions & 0 deletions
63
components/FeatureHighlight/docs/typical-use-highlight-a-view.md
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,63 @@ | ||
### Typical use: highlight a view | ||
|
||
<!--<div class="material-code-render" markdown="1">--> | ||
#### Swift | ||
```swift | ||
let completion = {(accepted: Bool) in | ||
// perform analytics here | ||
// and record whether the highlight was accepted | ||
} | ||
|
||
let highlightController = MDCFeatureHighlightViewController(highlightedView: viewToHighlight, | ||
completion: completion) | ||
highlightController.titleText = "Just how you want it" | ||
highlightController.bodyText = "Tap the menu button to switch accounts, change settings & more." | ||
highlightController.outerHighlightColor = | ||
UIColor.blue.withAlphaComponent(kMDCFeatureHighlightOuterHighlightAlpha) | ||
present(highlightController, animated: true, completion:nil) | ||
``` | ||
|
||
#### Objective-C | ||
```objc | ||
MDCFeatureHighlightCompletion completion = ^(BOOL accepted) { | ||
// perform analytics here | ||
// and record whether the highlight was accepted | ||
}; | ||
|
||
MDCFeatureHighlightViewController *highlightController = | ||
[[MDCFeatureHighlightViewController alloc] initWithHighlightedView:viewToHighlight | ||
completion:completion]; | ||
highlightController.titleText = @"Just how you want it"; | ||
highlightController.bodyText = @"Tap the menu button to switch accounts, change settings & more."; | ||
highlightController.outerHighlightColor = | ||
[[UIColor blueColor] colorWithAlphaComponent:kMDCFeatureHighlightOuterHighlightAlpha]; | ||
[self presentViewController:highlightController animated:YES completion:nil]; | ||
``` | ||
<!--</div>--> | ||
Often when highlighting a view you will want to display a different view to the one you are highlighting. For example, flipping the primary and secondary colors in the presented version. | ||
<!--<div class="material-code-render" markdown="1">--> | ||
#### Swift | ||
```swift | ||
let displayedButton = UIButton(type: .system) | ||
displayedButton.setTitle(highlightedButton.title(for: .normal), for: .normal) | ||
displayedButton.setTitleColor(highlightedButton.backgroundColor, for: .normal) | ||
displayedButton.backgroundColor = highlightedButton.titleColor(for: .normal) | ||
let highlightController = MDCFeatureHighlightViewController(highlightedView: highlightedButton, andShow: displayedButton, completion: completion) | ||
``` | ||
|
||
#### Objective-C | ||
```objc | ||
UIButton *displayedButton = [UIButton buttonWithType:UIButtonTypeSystem]; | ||
[displayedButton setTitle:[highlightedButton titleForState:UIControlStateNormal] | ||
forState:UIControlStateNormal]; | ||
[displayedButton setTitleColor:highlightedButton.backgroundColor forState:UIControlStateNormal]; | ||
displayedButton.backgroundColor = [highlightedButton titleColorForState:UIControlStateNormal]; | ||
MDCFeatureHighlightViewController *highlightController = | ||
[[MDCFeatureHighlightViewController alloc] initWithHighlightedView:highlightedButton | ||
andShowView:displayedButton | ||
completion:completion]; | ||
``` | ||
<!--</div>--> |