Skip to content

Commit

Permalink
feat(docs): overview-examples handling add
Browse files Browse the repository at this point in the history
  • Loading branch information
32penkin committed Jul 17, 2019
1 parent e88e90b commit 5b7cdeb
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 37 deletions.
1 change: 1 addition & 0 deletions docs/src/app/@theme/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@include nb-select-theme();
@include nb-input-theme();
@include nb-overlay-theme();
@include nb-radio-theme();

@include nb-typography();

Expand Down
4 changes: 4 additions & 0 deletions docs/src/app/blocks/blocks.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import {
NgdComponentsOverviewBlockComponent,
NgdTypesBlockComponent,
NgdHocParamsBlockComponent,
NgdOverviewExampleBlock,
} from './components/';
import { NbRadioModule } from '@nebular/theme';

const blocks = [
NgdMdBLockComponent,
Expand All @@ -57,13 +59,15 @@ const blocks = [
NgdComponentsOverviewBlockComponent,
NgdTypesBlockComponent,
NgdHocParamsBlockComponent,
NgdOverviewExampleBlock,
];

@NgModule({
imports: [
CommonModule,
RouterModule,
NgdThemeModule,
NbRadioModule,
],
declarations: [
...blocks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
background: $code-block-bg;
overflow-x: auto;

.language {
position: absolute;
right: 0.5rem;
top: 4rem;
}

.lines {
display: flex;
flex-direction: column;
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/blocks/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from './pager-block/pager-block.component';
export * from './components-overview-block/components-overview-block.component';
export * from './types-block/types-block.component';
export * from './hoc-params-block/hoc-params-block.component';
export * from './overview-example-block/overview-example-block.component';
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {
<ng-container>
<div [innerHTML]="description"
[ngStyle]="hasImage && {'margin-bottom': '16px'}"></div>
<ngd-overview-example
*ngFor="let example of source.overviewExamples"
[example]="example">
</ngd-overview-example>
<img
*ngFor="let image of images"
src={{image}}
Expand All @@ -44,7 +48,7 @@ export class NgdOverviewBlockComponent {
}

private prepareDescription(source): any {
this.description = source.description.replace('undefined', '');
this.description = source.description;
this.images = source.images.map((image: string) => `assets/images/overview/${image}`);
return source;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import {
ChangeDetectionStrategy,
Component,
Input,
} from '@angular/core';

@Component({
selector: 'ngd-overview-example',
template: `
<h5 style="margin-top: 2rem">{{title}}:</h5>
<ngd-code-block [code]="code"></ngd-code-block>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NgdOverviewExampleBlock {

code: any;
title: string;

@Input('example')
set example(value) {
this.code = value.code.replace(/```/g, '');
this.title = value.description;
}
}
47 changes: 14 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"conventional-changelog-cli": "^2.0.21",
"coveralls": "^3.0.2",
"del": "^4.1.1",
"doc-prsr": "^2.2.2",
"doc-prsr": "^2.2.3",
"gulp": "^3.9.1",
"gulp-replace": "^1.0.0",
"gulp-typedoc": "^2.2.1",
Expand Down
59 changes: 58 additions & 1 deletion src/framework/ui/button/button.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type ButtonProps = StyledComponentProps & TouchableOpacityProps & Compone
*
* @property StyledComponentProps
*
* @example Simple usage example
* @overview-example Simple usage example
*
* ```
* import React from 'react';
Expand All @@ -93,6 +93,32 @@ export type ButtonProps = StyledComponentProps & TouchableOpacityProps & Compone
* };
* ```
*
* @overview-example Eva-related props using example
*
* ```
* import React from 'react';
* import {
* Button,
* ButtonProps,
* } from 'react-native-ui-kitten';
*
* export const ButtonShowcase = (props?: ButtonProps): React.ReactElement<ButtonProps> => {
*
* const onPress = () => {
* // Handle Button press
* };
*
* return (
* <Button
* status='danger'
* size='large'
* onPress={onPress}>
* BUTTON
* </Button>
* );
* };
* ```
*
* @example Inline styling example
*
* ```
Expand All @@ -112,6 +138,37 @@ export type ButtonProps = StyledComponentProps & TouchableOpacityProps & Compone
* );
* };
* ```
*
* @example Button with Icon usage example
*
* ```
* import React from 'react';
* import {
* ImageStyle,
* Image,
* ImageProps,
* } from 'react-native';
* import {
* Button,
* ButtonProps,
* } from 'react-native-ui-kitten';
*
* const ButtonIcon = (style: ImageStyle): React.ReactElement<ImageProps> => {
* return (
* <Image style={style} source={{ uri: 'path/to/image' }}/>
* );
* };
*
* export const ButtonShowcase = (props?: ButtonProps): React.ReactElement<ButtonProps> => {
* return (
* <Button
* style={styles.button}
* icon={ButtonIcon}>
* BUTTON
* </Button>
* );
* };
* ```
*/

export class ButtonComponent extends React.Component<ButtonProps> {
Expand Down
2 changes: 1 addition & 1 deletion src/framework/ui/modal/modal.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type ModalProps = ViewProps & ComponentProps & ModalPresentingBased;
* @property {boolean} allowBackdrop - Determines whether user can tap on back-drop.
* Default is `false`.
*
* @property {{backgroundColor: string, opacity: number }} backdropStyle - Determines the style of backdrop.
* @property {BackdropStyle} backdropStyle - Determines the style of backdrop.
*
* @property {() => void} onBackdropPress - Determines component's behavior when the user is
* tapping on back-drop.
Expand Down

0 comments on commit 5b7cdeb

Please sign in to comment.