Skip to content
This repository was archived by the owner on Oct 17, 2020. It is now read-only.

Add SearchBar story #995

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
@import '../styles/color.scss';
@import '../styles/shadow.scss';
@import '../styles/layer';
@import '../styles/font';

.search-box {
@include default-font;
display: flex;
position: relative;
margin: 0 30px;
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/component/ui/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ChangeEvent, Component } from 'react';
import classNames from 'classnames';

import './SearchBar.scss';
import styles from './SearchBar.module.scss';
import { ShortLink } from '../../entity/ShortLink';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
Expand Down Expand Up @@ -51,8 +51,8 @@ export class SearchBar extends Component<Props, State> {

return (
<ul
className={classNames('suggestions', {
show: this.state.showAutoCompleteBox
className={classNames(styles.suggestions, {
[styles.show]: this.state.showAutoCompleteBox
})}
>
{this.props.autoCompleteSuggestions.map(e => (
Expand Down Expand Up @@ -80,8 +80,8 @@ export class SearchBar extends Component<Props, State> {

render() {
return (
<div className="search-box">
<div className="search-input">
<div className={`${styles['search-box']}`}>
<div className={`${styles['search-input']}`}>
<input
minLength={2}
maxLength={50}
Expand All @@ -90,7 +90,7 @@ export class SearchBar extends Component<Props, State> {
onFocus={this.showAutoCompleteBox}
onBlur={this.hideAutoCompleteBox}
/>
<div className={'search-icon'}>
<div className={`${styles['search-icon']}`}>
<Icon iconID={IconID.Search} />
</div>
</div>
Expand Down
25 changes: 25 additions & 0 deletions story/src/2-SearchBar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { SearchBar } from '../../frontend/src/component/ui/SearchBar';
import { action } from '@storybook/addon-actions';
import { withInfo } from '@storybook/addon-info';
import { withKnobs, object } from '@storybook/addon-knobs';

export default {
title: 'UI/SearchBar',
component: <SearchBar onChange={(_) => {}} />,
decorators: [withKnobs, withInfo({ header: false, inline: true })]
};

export const standard = () => {
return (
<SearchBar
onChange={action('change')}
autoCompleteSuggestions={object('Search Results', [
{
longLink: 'https://www.google.com/',
alias: 'google'
}
])}
/>
);
};