Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert glamorous to styled-components #12 #950

Merged
merged 13 commits into from
Sep 19, 2018
Merged
1 change: 0 additions & 1 deletion gsa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"downshift": "^1.31.6",
"fast-deep-equal": "^1.1.0",
"glamor": "^2.20.40",
"glamorous": "^4.13.1",
"history": "^4.7.2",
"hoist-non-react-statics": "^2.5.5",
"i18next": "^11.3.3",
Expand Down
6 changes: 5 additions & 1 deletion gsa/src/web/stories/chart/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
*/
import React from 'react';

import {Div} from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';

import BarChart from 'web/components/chart/bar';

const Div = styled.div`
color: ${props => props.color}
`;

const bardata = [{
label: 'Foo',
x: 'foo',
Expand Down
11 changes: 8 additions & 3 deletions gsa/src/web/stories/chart/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@
*/
import React from 'react';

import {Div} from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';

import Legend, {Label, Item, Line} from 'web/components/chart/legend';

const Div = styled.div`
display: flex;
margin: ${props => props.margin};
`;

const data = [
{
label: 'G',
Expand Down Expand Up @@ -61,14 +66,14 @@ const data = [
storiesOf('Chart/Legend', module)
.add('default', () => {
return (
<Div display="flex">
<Div>
<Legend data={data}/>
</Div>
);
})
.add('line', () => {
return (
<Div display="flex" margin="50">
<Div margin="50">
<Legend
data={[{
color: 'red',
Expand Down
14 changes: 8 additions & 6 deletions gsa/src/web/stories/chart/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
import React from 'react';

import {Div} from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';

Expand All @@ -31,6 +31,12 @@ import HostsTopologyChart from 'web/components/chart/topology';
import hosts from './hosts.json';
import links from './links.json';

const Div = styled.div`
border: 1px solid black;
margin: 25px;
display: inline-flex;
`;

const simpledata = {
hosts: [{
id: '192.168.123.73',
Expand Down Expand Up @@ -68,11 +74,7 @@ storiesOf('Chart/Topology', module)
))
.add('Big Network', () => {
return (
<Div
border="1px solid black"
margin="25px"
display="inline-flex"
>
<Div>
<HostsTopologyChart
width={500}
height={300}
Expand Down
8 changes: 7 additions & 1 deletion gsa/src/web/stories/dashboard/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
import React from 'react';

import {Div} from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';
import {action} from '@storybook/addon-actions';
Expand All @@ -34,6 +34,12 @@ import DisplayMenu from 'web/components/dashboard/display/displaymenu';

const removeaction = action('on remove click');

const Div = styled.div`
width: ${props => props.width};
height: ${props => props.height};
background-color: ${props => props.backgroundColor};
`;

storiesOf('Dashboard/Display', module)
.add('default', () => {
return (
Expand Down
16 changes: 8 additions & 8 deletions gsa/src/web/stories/datepicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

import React from 'react';
import glamorous from 'glamorous';
import styled from 'styled-components';

import date from 'gmp/models/date';

Expand Down Expand Up @@ -68,13 +68,13 @@ ControlledDatePicker.propTypes = {
value: PropTypes.date,
};

const StyledDatePicker = glamorous(ControlledDatePicker)({
border: '1px solid darkgreen',
background: 'lightgreen',
boxShadow: '5px 5px 10px black',
fontFamily: 'Trebuchet MS,Tahoma,Verdana,Arial,sans-serif',
fontSize: '14px',
});
const StyledDatePicker = styled(ControlledDatePicker)`
border: 1px solid darkgreen;
background: lightgreen;
box-shadow: 5px 5px 10px black;
font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif;
font-size: 14px;
`;

storiesOf('Form/Datepicker', module)
.add('default', () => {
Expand Down
42 changes: 21 additions & 21 deletions gsa/src/web/stories/multiselect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
import React from 'react';

import glamorous from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';
import {action} from '@storybook/addon-actions';
Expand All @@ -32,34 +32,34 @@ import Divider from 'web/components/layout/divider.js';

import os from 'web/utils/os.js';

const Sizer = glamorous.div({
width: '300px',
});
const Sizer = styled.div`
width: 300px;
`;

const Box = glamorous.div({
width: '150px',
height: '50px',
border: '1px solid grey',
padding: '5px',
display: 'flex',
alignItems: 'center',
});
const Box = styled.div`
width: 150px;
height: 50px;
border: 1px solid grey;
padding: 5px;
display: flex;
align-items: center;
`;

const items = os.operating_systems.map(o => ({
value: o.pattern,
label: o.title,
}));

const SelectBox = glamorous.div({
width: '120px', // this is the recommended minimum for MultiSelect
border: '1px solid blue',
padding: '5px',
});
const SelectBox = styled.div`
width: 120px; /* this is the recommended minimum for MultiSelect */
border: 1px solid blue;
padding: 5px;
`;

const StyledSelect = glamorous(MultiSelect)({
width: '120px',
height: '30px',
});
const StyledSelect = styled(MultiSelect)`
width: 120px;
height: 30px;
`;

class ControlledMultiSelect extends React.Component {

Expand Down
12 changes: 6 additions & 6 deletions gsa/src/web/stories/powerfilter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
import React from 'react';

import glamorous from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';

Expand All @@ -40,11 +40,11 @@ const fakegmp = {
},
};

const Box = glamorous.div({
display: 'flex',
padding: '5px',
border: '1px solid black',
});
const Box = styled.div`
display: flex;
padding: 5px;
border: 1px solid black;
`;

storiesOf('Powerfilter', module)
.add('default', () => (
Expand Down
48 changes: 24 additions & 24 deletions gsa/src/web/stories/select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
import React from 'react';

import glamorous from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';
import {action} from '@storybook/addon-actions';
Expand All @@ -32,29 +32,29 @@ import Divider from 'web/components/layout/divider.js';

import os from 'web/utils/os.js';

const Sizer = glamorous.div({
width: '300px',
});

const Box = glamorous.div({
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
width: '200px',
border: '1px solid grey',
padding: '5px',
});

const SelectBox = glamorous.div({
width: '100px',
border: '1px solid blue',
padding: '5px',
});

const StyledSelect = glamorous(Select)({
height: '30px',
});
const Sizer = styled.div`
width: 300px;
`;

const Box = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 200px;
border: 1px solid grey;
padding: 5px;
`;

const SelectBox = styled.div`
width: 100px;
border: 1px solid blue;
padding: 5px;
`;

const StyledSelect = styled(Select)`
height: 30px;
`;

const items = os.operating_systems.map(o => ({
value: o.pattern,
Expand Down
14 changes: 7 additions & 7 deletions gsa/src/web/stories/sortable/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
import React from 'react';

import glamorous from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';

Expand Down Expand Up @@ -61,12 +61,12 @@ class ItemController extends React.Component {
}
}

const Item = glamorous.span({
flexGrow: '1',
backgroundColor: 'blue',
padding: '5px',
color: 'white',
});
const Item = styled.span`
flex-grow: 1;
background-color: blue;
padding: 5px;
color: white;
`;

const getItems = (row, count) =>
Array.from({length: count}, (v, k) => k).map(k =>
Expand Down
14 changes: 9 additions & 5 deletions gsa/src/web/stories/sortable/resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,26 @@
*/
import React from 'react';

import {Div} from 'glamorous';
import styled from 'styled-components';

import {storiesOf} from '@storybook/react';

import Resizer from 'web/components/sortable/resizer';

const Div = styled.div`
display: flex;
width: 400px;
background-color: blue;
height: ${props => props.height}px;
`;

class ResizeContainer extends React.Component {

constructor(...args) {
super(...args);

this.state = {
height: '100px',
height: '100',
};

this.handleResize = this.handleResize.bind(this);
Expand All @@ -54,9 +61,6 @@ class ResizeContainer extends React.Component {
return (
<div>
<Div
display="flex"
width="400px"
backgroundColor="blue"
height={height}
innerRef={ref => this.div = ref}
/>
Expand Down
Loading