I have a very basic component that displays the Page Header (<h1>
tags) and Sub Headers (<h3>
tags) so if I want to update any styling or add specific functionality, I can update it in one place.
With this, I'm working on a styled-components, but I'm not able to get it to work. I've taken a look here, which is a great starting example, but I wish it was completed with the full written example so I can see what I'm doing wrong.
I'm trying to get my select
tag next to my header tag. I was able to get this to work with just the raw/exact html, but when I try to implement it into a component, I can't seem to get it to work. Any thoughts on what I'm doing wrong?
Here is my code:
PageHeaderSubSection.js
import React from 'react'
export default class PageHeaderSubSection extends React.Component {
render() {
return (
<h3 className="header-sub-content header-sub-name">
{this.props.children}
</h3>
)
}
}
MainPage.js
import React from 'react'
import styled from 'styled-components'
import PageHeader from '../common/page/PageHeader'
import PageHeaderSubSection from '../common/page/PageHeaderSubSection'
const StyledPageHeaderSubSection = styled(PageHeaderSubSection)``
const FormHeaderWithButtonStyle = styled.div`
${StyledPageHeaderSubSection} {
margin: 0;
display: inline-block;
}
select {
vertical-align: text-bottom;
}
`
class MainPage extends React.Component {
render() {
return (
<>
<PageHeader>Main</PageHeader>
<FormHeaderWithButtonStyle>
<PageHeaderSubSection>Main Modifiable Data</PageHeaderSubSection>
<span> </span>
<select className="form-control w-auto" >
<option key={0} value={0}>None</option>
<option key={1} value={"Select 1"}>{"Select 1"}</option>
<option key={2} value={"Select 2"}>{"Select 2"}</option>
<option key={3} value={"Select 3"}>{"Select 3"}</option>
</select>
</FormHeaderWithButtonStyle>
<MoreDataHere />
</>
)
}
}