Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat: set search to sticky
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Sep 10, 2018
1 parent b43b8c0 commit fc1c8fe
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/components/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface SearchProps {

const StyledContainer = styled.div`
position: relative;
padding: 0 ${getSpace(SpaceSize.M)}px;
`;

const StyledSearch = styled.input`
Expand Down Expand Up @@ -61,8 +62,8 @@ const StyledSearch = styled.input`

const StyledIcon = styled(Icon.Search)`
position: absolute;
left: 0;
top: ${getSpace(SpaceSize.M) - 1}px; // fix to propertly align icon
left: ${getSpace(SpaceSize.M)}px;
top: ${getSpace(SpaceSize.M) - 1}px; /* fix to propertly align icon */
pointer-events: none;
`;

Expand Down
53 changes: 33 additions & 20 deletions src/container/pattern-list/pattern-list-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as MobxReact from 'mobx-react';
import * as Model from '../../model';
import { PatternItemContainer } from './pattern-item-container';
import * as React from 'react';
import styled from 'styled-components';
import * as Types from '../../types';
import { ViewStore } from '../../store';

Expand Down Expand Up @@ -31,27 +32,39 @@ export class PatternListContainer extends React.Component {
const searchResult = project.getPatternSearch().query(store.getPatternSearchTerm());

return (
<div onDragStart={e => this.handleDragStart(e)}>
<Components.Space sizeBottom={Components.SpaceSize.XXS}>
<Components.Search
placeholder="Search Library"
onChange={e => store.setPatternSearchTerm(e.target.value)}
value={store.getPatternSearchTerm()}
/>
</Components.Space>
{store
.getPatternLibraries()
.map(library => (
<PatternLibraryContainer
key={library.getId()}
library={library}
searchResult={searchResult}
<div>
<div
style={{
position: 'sticky',
top: 0,
backgroundColor: Components.Color.Grey97,
marginLeft: -1 * Components.getSpace(Components.SpaceSize.M),
marginRight: -1 * Components.getSpace(Components.SpaceSize.M)
}}
>
<Components.Space sizeBottom={Components.SpaceSize.XXS}>
<Components.Search
placeholder="Search Library"
onChange={e => store.setPatternSearchTerm(e.target.value)}
value={store.getPatternSearchTerm()}
/>
))}
<ElementDragImage
element={store.getDraggedElement()}
innerRef={ref => (this.dragImg = ref)}
/>
</Components.Space>
</div>
<div onDragStart={e => this.handleDragStart(e)} style={{}}>
{store
.getPatternLibraries()
.map(library => (
<PatternLibraryContainer
key={library.getId()}
library={library}
searchResult={searchResult}
/>
))}
<ElementDragImage
element={store.getDraggedElement()}
innerRef={ref => (this.dragImg = ref)}
/>
</div>
</div>
);
}
Expand Down

0 comments on commit fc1c8fe

Please sign in to comment.