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

theme not passing to all Grid,Rows,Col as desired... #95

Open
robertschank opened this issue Jan 4, 2018 · 4 comments
Open

theme not passing to all Grid,Rows,Col as desired... #95

robertschank opened this issue Jan 4, 2018 · 4 comments

Comments

@robertschank
Copy link

robertschank commented Jan 4, 2018

desired outcome:

All descendents of which are Grid, Rows and Cols take config from theme in the index.js file

actual behavior:

default gutterwidth and outerMargin are passed unless theme is directly called.

So we are presently passing theme over and over again down the app.... (see portion of code below)

What could I/we do differently to get the desired outcome?

in our /index.js

const theme = {
  flexboxgrid: {
    gutterWidth: 0,
    outerMargin: 0,
    breakpoints: {
      xs: 0,  // em
      sm: 48, // em
      md: 64, // em
      lg: 75 // em
    }
  }
};

render(
    <ThemeProvider theme={theme}>
      <App />
    </ThemeProvider>
  , document.getElementById('root'));

in our App.js lots of props passing using Styled-Components withTheme(Component)

class App extends React.Component {
  componentWillMount() {
    this.props.fetchConfig();
  }

  render() {
    return (
      <Grid fluid theme={this.props.theme}>
        <Row theme={this.props.theme}>
          <Col xs={12} theme={this.props.theme}><Header /></Col>
        </Row>
        <Row theme={this.props.theme}>
          <Col xs={12} theme={this.props.theme}>
            <Route component={CatchAllComponent} />
            <Route path="/login" component={LoginComponent} />
            <Route path="/forgotPassword" component={ForgotPassword} />
          </Col>
        </Row>
        <Row theme={this.props.theme}>
          <Col xs={12} theme={this.props.theme}><Footer /></Col>
        </Row>
      </Grid>
    );
  }
}
export default (withTheme(App));

just to explain the madness; it continues to each child component
this is login/index.js

    return (
      <MainSection theme={this.props.theme}>
        <LoginContainer>
          <LoginFieldRow>
            <Col xs={12}>
              <LoginTitle>
                Please Sign In
              </LoginTitle>
            </Col>
          </LoginFieldRow>
          <LoginFieldRow>
            {this.handleErrorCase()}
            {this.hasAuthKeys()}

            <Col xs={12}>
              <TextField
                type="text"
                label="Your Email Address"
                value={this.state.email}
                onChange={this.emailOnChange}
              />
            </Col>
          </LoginFieldRow>
          <LoginFieldRow>
            <Col xs={12}>
              <TextField
                type="password"
                label="Password"
                value={this.state.password}
                onChange={this.passwordOnChange}
              />
            </Col>
          </LoginFieldRow>
          <LoginButtonRow>
            <Col xs={12}>
              <LoginButton type="primary" onClick={this.loginHandler}>
                Sign In
              </LoginButton>
            </Col>
          </LoginButtonRow>
          <LoginLinkRow>
            <LinkDiv>
              <Link to="/forgotPassword">Forgot your password?</Link>
            </LinkDiv>
            <LinkDiv>
              <Link to="/login">Not a member?</Link>
            </LinkDiv>
          </LoginLinkRow>
        </LoginContainer>
        <ContactMessage />
      </MainSection>
    );
  }
}

We'd need to continue with all of and its

blah

May be related to:

#84
#19

@misund
Copy link
Contributor

misund commented Jan 26, 2018

I cannot reproduce your issue with gutterWidth.

In shiny, we're using a patched version of the Grid component to fix #19, but use Row and Col as provided - that works as expected, without wrapping our App component in withTheme, and without passing the theme around manually.

Here's our Grid story. Switch between the "Default" and "Oppskrift" themes in the top navigation bar to see that the gutterWidth changes dynamically.

@misund
Copy link
Contributor

misund commented Jan 26, 2018

Here's our modified Grid component

@misund
Copy link
Contributor

misund commented Aug 21, 2018

Do you still have issues after #87 was merged?

@kevryan2
Copy link

kevryan2 commented Nov 14, 2019

@misund I'm experiencing this issue currently on the latest version - unless I place theme={theme} on every single child row and column (where theme = the provided example theme object in the Readme), the props of theme.flexboxgrid.gutterWidth and theme.flexboxgrid.outerMargin don't actually get read or used. This includes if I use container="fluid". If I place theme on every single , it all works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants