Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Customize cliqz-component #15

Open
mai-cliqz opened this issue Jul 16, 2019 · 2 comments
Open

Customize cliqz-component #15

mai-cliqz opened this issue Jul 16, 2019 · 2 comments

Comments

@mai-cliqz
Copy link
Contributor

mai-cliqz commented Jul 16, 2019

import React from 'react';
import { MovieShowtimes as Showtimes } from '@cliqz/component-ui-movie-showtimes';
import { useTheme } from '@material-ui/core/styles';
import useMediaQuery from '@material-ui/core/useMediaQuery';

const match = (query) => useMediaQuery(query);

const styles = (theme) => ({
  cinemaContainer: {
    maxWidth: theme.consts.CONTAINER_MAX_WIDTH,
    alignItems: match([theme.breakpoints.down('sm')]) ? 'center' : 'flex-start',
  },
  cinemaAddressText: {
    color: theme.palette.grey.primary,
    fontSize: theme.typography.h2,
    fontWeight: 600, // New property
  }
});

export default function MovieShowtimes(props) {
  const theme = useTheme();
  
  return (
    <div>
      <Showtimes data={props.result} styles={styles(theme)} />
    </div>
  );
}
@chrmod
Copy link
Member

chrmod commented Jul 16, 2019

I don't think you can use theme.breakpoints. as styles will be passed to Stylesheet.create which does not support media queries. You should rather pass exact value to style property based on current size.

const styles = (theme) => ({
  cinemaContainer: {
    maxWidth: theme.consts.CONTAINER_MAX_WIDTH,
    alignItems: theme.dimensions === 'sm' ? 'flex-start' : 'center',
  }
};

I don't know MUI but I assume there is some way to check dimensions like theme.dimensions === 'sm'

@mai-cliqz
Copy link
Contributor Author

Just updated it to make use of useMediaQuery. For now we pass exact value only

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

No branches or pull requests

2 participants