Skip to content

Commit

Permalink
feat(web): custom tag for ReactiveBase
Browse files Browse the repository at this point in the history
  • Loading branch information
bietkul committed Jul 24, 2019
1 parent 452dfac commit 422d37a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/web/src/components/basic/ReactiveBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface ReactiveBaseProps {
app: string;
children?: types.children;
credentials?: string;
as?: string;
headers?: types.headers;
queryParams?: string;
theme?: types.style;
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/components/basic/ReactiveBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import URLParamsProvider from './URLParamsProvider';
import getTheme from '../../styles/theme';
import { composeThemeObject, ReactReduxContext } from '../../utils';


class ReactiveBase extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -122,6 +121,7 @@ class ReactiveBase extends Component {
<URLParamsProvider
headers={this.props.headers}
style={this.props.style}
as={this.props.as}
className={this.props.className}
getSearchParams={this.props.getSearchParams}
setSearchParams={this.props.setSearchParams}
Expand All @@ -141,11 +141,13 @@ ReactiveBase.defaultProps = {
analytics: false,
searchStateHeader: false,
graphQLUrl: '',
as: 'div',
};

ReactiveBase.propTypes = {
app: types.stringRequired,
searchStateHeader: types.bool,
as: types.string,
children: types.children,
credentials: types.string,
headers: types.headers,
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/components/basic/URLParamsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class URLParamsProvider extends Component {

render() {
return (
<Base style={this.props.style} className={this.props.className}>
<Base as={this.props.as} style={this.props.style} className={this.props.className}>
{this.props.children}
</Base>
);
Expand All @@ -207,6 +207,7 @@ URLParamsProvider.propTypes = {
selectedValues: types.selectedValues,
// component props
children: types.children,
as: types.string,
headers: types.headers,
style: types.style,
className: types.string,
Expand All @@ -217,6 +218,7 @@ URLParamsProvider.propTypes = {
URLParamsProvider.defaultProps = {
style: {},
className: null,
as: 'div',
};

const mapStateToProps = state => ({
Expand Down
12 changes: 9 additions & 3 deletions packages/web/src/styles/Base.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import React from 'react';
import styled from 'react-emotion';

const Base = styled('div')`
const Base = styled(({ as: T = 'div', ...props }) => <T {...props} />)`
font-family: ${({ theme }) => theme.typography.fontFamily};
font-size: ${({ theme }) => theme.typography.fontSize};
color: ${({ theme }) => theme.colors.textColor};
width: 100%;
input, button, textarea, select {
input,
button,
textarea,
select {
font-family: ${({ theme }) => theme.typography.fontFamily};
}
*, *:before, *:after {
*,
*:before,
*:after {
box-sizing: border-box;
}
`;
Expand Down

0 comments on commit 422d37a

Please sign in to comment.