Commit ba3a81ab by Johannes Schill

ux: Add CTA for empty lists

parent 15f46b85
import { react2AngularDirective } from 'app/core/utils/react2angular'; import { react2AngularDirective } from 'app/core/utils/react2angular';
import { PasswordStrength } from './components/PasswordStrength'; import { PasswordStrength } from './components/PasswordStrength';
import PageHeader from './components/PageHeader'; import PageHeader from './components/PageHeader';
import EmptyListCTA from './components/EmptyListCTA/EmptyListCTA';
export function registerAngularDirectives() { export function registerAngularDirectives() {
react2AngularDirective('passwordStrength', PasswordStrength, ['password']); react2AngularDirective('passwordStrength', PasswordStrength, ['password']);
react2AngularDirective('pageHeader', PageHeader, ['model', "noTabs"]); react2AngularDirective('pageHeader', PageHeader, ['model', "noTabs"]);
react2AngularDirective('emptyListCta', EmptyListCTA, ['model']);
} }
import React from 'react';
import renderer from 'react-test-renderer';
import EmptyListCTA from './EmptyListCTA';
const model = {
title: 'Title',
buttonIcon: 'ga css class',
buttonLink: 'http://url/to/destination',
buttonTitle: 'Click me',
proTip: 'This is a tip',
proTipLink: 'http://url/to/tip/destination',
proTipLinkTitle: 'Learn more',
proTipTarget: '_blank'
};
describe('CollorPalette', () => {
it('renders correctly', () => {
const tree = renderer.create(<EmptyListCTA model={model} />).toJSON();
expect(tree).toMatchSnapshot();
});
});
import React, { Component } from 'react';
export interface IProps {
model: any;
}
class EmptyListCTA extends Component<IProps, any> {
render() {
const {
title,
buttonIcon,
buttonLink,
buttonTitle,
proTip,
proTipLink,
proTipLinkTitle,
proTipTarget
} = this.props.model;
return (
<div className="empty-list-cta p-t-2 p-b-1">
<div className="empty-list-cta__title">{title}</div>
<a href={buttonLink} className="empty-list-cta__button btn btn-xlarge btn-success"><i className={buttonIcon} />{buttonTitle}</a>
<div className="empty-list-cta__pro-tip">
<i className="fa fa-rocket" /> ProTip: {proTip}
<a className="text-link empty-list-cta__pro-tip-link"
href={proTipLink}
target={proTipTarget}>{proTipLinkTitle}</a>
</div>
</div>
);
}
}
export default EmptyListCTA;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CollorPalette renders correctly 1`] = `
<div
className="empty-list-cta p-t-2 p-b-1"
>
<div
className="empty-list-cta__title"
>
Title
</div>
<a
className="empty-list-cta__button btn btn-xlarge btn-success"
href="http://url/to/destination"
>
<i
className="ga css class"
/>
Click me
</a>
<div
className="empty-list-cta__pro-tip"
>
<i
className="fa fa-rocket"
/>
ProTip:
This is a tip
<a
className="text-link empty-list-cta__pro-tip-link"
href="http://url/to/tip/destination"
target="_blank"
>
Learn more
</a>
</div>
</div>
`;
<page-header model="ctrl.navModel"></page-header> <page-header model="ctrl.navModel"></page-header>
<div class="page-container page-body"> <div class="page-container page-body">
<div ng-if="ctrl.datasources.length">
<div class="page-action-bar"> <div class="page-action-bar">
<div class="page-action-bar__spacer"></div> <div class="page-action-bar__spacer"></div>
<a class="page-header__cta btn btn-success" href="datasources/new"> <a class="page-header__cta btn btn-success" href="datasources/new">
...@@ -39,8 +40,18 @@ ...@@ -39,8 +40,18 @@
</li> </li>
</ol> </ol>
</section> </section>
</div>
<div ng-if="ctrl.datasources.length === 0"> <div ng-if="ctrl.datasources.length === 0">
<em>No data sources defined</em> <empty-list-cta model="{
title: 'There are no data sources defined yet',
buttonIcon: 'gicon gicon-dashboard-new',
buttonLink: '/datasources/new',
buttonTitle: 'Add data source',
proTip: 'You can also define data sources through configuration files.',
proTipLink: 'http://docs.grafana.org/administration/provisioning/#datasources',
proTipLinkTitle: 'Learn more',
proTipTarget: '_blank'
}" />
</div> </div>
</div> </div>
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
@import "components/dashboard_grid"; @import "components/dashboard_grid";
@import "components/dashboard_list"; @import "components/dashboard_list";
@import "components/page_header"; @import "components/page_header";
@import "components/empty_list_cta";
// PAGES // PAGES
......
...@@ -218,8 +218,11 @@ $btn-font-weight: 500 !default; ...@@ -218,8 +218,11 @@ $btn-font-weight: 500 !default;
$btn-padding-x-sm: .5rem !default; $btn-padding-x-sm: .5rem !default;
$btn-padding-y-sm: .25rem !default; $btn-padding-y-sm: .25rem !default;
$btn-padding-x-lg: 1.5rem !default; $btn-padding-x-lg: 21px !default;
$btn-padding-y-lg: .75rem !default; $btn-padding-y-lg: 11px !default;
$btn-padding-x-xl: 21px !default;
$btn-padding-y-xl: 11px !default;
$btn-border-radius: 3px; $btn-border-radius: 3px;
......
...@@ -48,6 +48,8 @@ a.text-success:hover, ...@@ -48,6 +48,8 @@ a.text-success:hover,
a.text-success:focus { color: darken($success-text-color, 10%); } a.text-success:focus { color: darken($success-text-color, 10%); }
a { cursor: pointer; } a { cursor: pointer; }
.text-link { text-decoration: underline; }
a:focus { a:focus {
outline:0 none !important; outline:0 none !important;
} }
......
...@@ -51,10 +51,21 @@ ...@@ -51,10 +51,21 @@
// Button Sizes // Button Sizes
// -------------------------------------------------- // --------------------------------------------------
// XLarge
.btn-xlarge {
@include button-size($btn-padding-y-xl, $btn-padding-x-xl, $font-size-lg, $btn-border-radius);
font-weight: normal;
padding-bottom: $btn-padding-y-xl - 3;
.gicon {
font-size: 31px;
margin-right: 1rem;
}
}
// Large // Large
.btn-large { .btn-large {
@include button-size($btn-padding-y-lg, $btn-padding-x-lg, $font-size-lg, $btn-border-radius); @include button-size($btn-padding-y-lg, $btn-padding-x-lg, $font-size-lg, $btn-border-radius);
font-weight: normal;
} }
.btn-small { .btn-small {
......
.empty-list-cta {
background-color: $search-filter-box-bg;
text-align: center;
}
.empty-list-cta__title {
padding-bottom: 30px;
font-style: italic;
}
.empty-list-cta__button {
margin-bottom: 50px;
}
.empty-list-cta__pro-tip {
padding-bottom: 20px;
}
.empty-list-cta__pro-tip-link {
margin-left: 5px;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment