Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit bb7639c

Browse files
authored
Merge pull request #65 from strapi/improve-header
Improve header
2 parents b766691 + 4ae71db commit bb7639c

File tree

5 files changed

+57
-7
lines changed

5 files changed

+57
-7
lines changed

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
99
"storybook": "start-storybook -p 6006",
10+
"develop": "start-storybook -p 6006",
1011
"build-storybook": "build-storybook"
1112
},
1213
"author": "",

docs/stories/customComponents/Header.stories.js

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@ import React from 'react';
33
import { storiesOf } from '@storybook/react';
44

55
import { Header } from '@buffetjs/custom';
6+
import { InputText } from '@buffetjs/core';
7+
import styled from 'styled-components';
68

79
import Presentation from '../ui/Presentation';
810
import Pre from '../ui/Pre';
911

12+
const Wrapper = styled.div`
13+
padding-top: 9px;
14+
margin-bottom: 35px;
15+
16+
.input-wrapper {
17+
margin-left: 1.8rem;
18+
height: 30px;
19+
> input {
20+
height: 30px;
21+
}
22+
}
23+
`;
24+
1025
function HeaderStory() {
1126
const cta = {
1227
icon: 'fa fa-pencil',
@@ -26,6 +41,13 @@ function HeaderStory() {
2641
color: 'success',
2742
type: 'submit',
2843
},
44+
// Passing custom component
45+
{
46+
Component: InputText,
47+
className: 'input-wrapper',
48+
name: 'example',
49+
key: 'example',
50+
},
2951
];
3052

3153
const props = {
@@ -39,9 +61,9 @@ function HeaderStory() {
3961

4062
return (
4163
<Presentation title="Header" description="Display data.">
42-
<div style={{ paddingTop: 9, marginBottom: 35 }}>
64+
<Wrapper>
4365
<Header {...props} />
44-
</div>
66+
</Wrapper>
4567
<Pre>{source}</Pre>
4668
</Presentation>
4769
);
@@ -50,6 +72,21 @@ function HeaderStory() {
5072
const source = `
5173
import React, { useState } from 'react';
5274
import { Header } from '@buffetjs/custom';
75+
import { InputText } from '@buffetjs/core';
76+
import styled from 'styled-components';
77+
78+
const Wrapper = styled.div\`
79+
padding-top: 9px;
80+
margin-bottom: 35px;
81+
82+
.input-wrapper {
83+
margin-left: 1.8rem;
84+
height: 30px;
85+
> input {
86+
height: 30px;
87+
}
88+
}
89+
\`;
5390
5491
function Example() {
5592
const cta = {
@@ -70,6 +107,12 @@ function Example() {
70107
color: 'success',
71108
type: 'submit',
72109
},
110+
// Passing custom component
111+
{
112+
Component: InputText,
113+
className: 'input-wrapper',
114+
name: 'example',
115+
},
73116
];
74117
75118
const headerProps = {
@@ -82,7 +125,9 @@ function Example() {
82125
};
83126
84127
return (
85-
<Header {...headerProps} />
128+
<Wrapper>
129+
<Header {...headerProps} />
130+
</Wrapper>
86131
);
87132
}`;
88133

packages/buffetjs-core/src/components/HeaderActions/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ import Button from '../Button';
1313
function HeaderActions({ actions }) {
1414
return (
1515
<Wrapper>
16-
{actions.map(action => {
17-
const { disabled, title, onClick } = action;
16+
{actions.map((action, index) => {
17+
const { Component, disabled, title, onClick } = action;
18+
19+
if (Component) {
20+
return <Component {...action} key={action.key || index} />;
21+
}
1822

1923
return (
2024
<Button

packages/buffetjs-styles/src/components/HeaderActions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const HeaderActions = styled.div`
1212
width: fit-content;
1313
max-width: 100%;
1414
padding-top: 1rem;
15-
button {
15+
> button {
1616
margin-right: 0;
1717
margin-left: 1.8rem;
1818
max-width: 100%;

packages/buffetjs-styles/src/components/HeaderActions/tests/__snapshots__/index.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports[`<HeaderActions /> snapshot 1`] = `
1717
padding-top: 1rem;
1818
}
1919
20-
.c0 button {
20+
.c0 > button {
2121
margin-right: 0;
2222
margin-left: 1.8rem;
2323
max-width: 100%;

0 commit comments

Comments
 (0)