GithubHelp home page GithubHelp logo

llorentegerman / simple-flexbox Goto Github PK

View Code? Open in Web Editor NEW
38.0 38.0 6.0 1.09 MB

A simple way to make responsive layouts using Flexbox in React

License: MIT License

JavaScript 75.25% TypeScript 24.75%

simple-flexbox's People

Contributors

dependabot[bot] avatar faq885 avatar llorentegerman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simple-flexbox's Issues

ref is not supporting

I've tried to get offsetWidth from Column's ref.current, but it prints undefined.
We need to support ref.

It's not works

      <Column  ref={this.thisComponent}>
        <div>test</div>
        <div>test2</div>
      </Column>

It works

      <div ref={this.thisComponent}>
        <div>test</div>
        <div>test2</div>
      </div>

By the way material-ui supports ref this way although it uses hook
https://github.com/mui-org/material-ui/blob/5301c24c3be1023efcec7e33bd7e7f030a87c0cb/packages/material-ui/src/Typography/Typography.js#L122-L163

const Typography = React.forwardRef(function Typography(props, ref) {
  const {
    align = 'inherit',
    classes,
    className,
    color = 'initial',
    component,
    display = 'initial',
    gutterBottom = false,
    noWrap = false,
    paragraph = false,
    theme,
    variant = 'body1',
    variantMapping = defaultVariantMapping,
    ...other
  } = props;


  const Component =
    component ||
    (paragraph ? 'p' : variantMapping[variant] || defaultVariantMapping[variant]) ||
    'span';


  return (
    <Component
      className={clsx(
        classes.root,
        {
          [classes[variant]]: variant !== 'inherit',
          [classes[`color${capitalize(color)}`]]: color !== 'initial',
          [classes.noWrap]: noWrap,
          [classes.gutterBottom]: gutterBottom,
          [classes.paragraph]: paragraph,
          [classes[`align${capitalize(align)}`]]: align !== 'inherit',
          [classes[`display${capitalize(display)}`]]: display !== 'initial',
        },
        className,
      )}
      ref={ref}
      {...other}
    />
  );
});

Issue while building

I'm having this issue while building my Gatsby website, any idea how to fix it?

`

"window" is not available during server side rendering.

See our docs page for more info on this error: https://gatsby.dev/debug-html

497 | return _extends({}, style, window.innerWidth <= +key ? { flexDirection: value } : {});
498 | }

499 | return _extends({}, style, window.innerWidth <= +key ? value : {});
| ^
500 | }, {});
501 |
502 | var classNames = ((className || '') + ' ' + breakpointsClassNames.join(' ')).trim();

WebpackError: ReferenceError: window is not defined

  • index.js:499
    node_modules/simple-flexbox/build/index.js:499:35

  • index.js:485 Layout.render
    node_modules/simple-flexbox/build/index.js:485:14

`

image

Typescript is not supported

Note: I pull requested this issue see: #3

When I type npm install @types/simple-flexbox the "Not found" error occurred so we need to support type declaration for it.

Apart from it I made my own declaration file :

/// <reference types="react" />

declare module 'simple-flexbox' {
    declare class Column extends React.Component<ColumnProps> {}
    declare class Row extends React.Component<RowProps> {}

    declare interface ColumnProps {
        onClick?: (e: React.MouseEvent) => void;
        className?: string
        style?: React.CSSProperties
        flexGrow?: number
        wrap?: boolean
        flex?: string,
        flexShrink?: number
        flexBasis?: string
        breakpoints?: object
        reverse?: boolean
        children: any
        vertical?: 'start' | 'center' | 'end' | 'spaced' | 'space-between' | 'around' | 'space-around' | 'space-evenly'
        horizontal?: 'start' | 'center' | 'end' | 'stretch'
        justifyContent?: 'start' | 'flex-start' | 'center' | 'end' | 'flex-end' | 'spaced' | 'space-between' | 'around' | 'space-around' | 'space-evenly'
        alignItems?: 'start' | 'center' | 'end' | 'stretch' | 'baseline'
        alignSelf?: 'start' | 'center' | 'end' | 'stretch' | 'baseline'
        alignContent?: 'start' | 'flex-start' | 'center' | 'end' | 'flex-end' | 'spaced' | 'space-between' | 'around' | 'space-around' | 'stretch'
    }

    declare interface RowProps {
        onClick?: (e: React.MouseEvent) => void;
        className?: string
        style?: React.CSSProperties
        wrap?: boolean
        reverse?: boolean
        flex?: string
        flexGrow?: number
        flexShrink?: number
        flexBasis?: string
        breakpoints?: object
        children: any
        vertical?: 'start' | 'center' | 'end' | 'spaced' | 'baseline'
        horizontal?: 'start' | 'center' | 'end' | 'spaced' | 'space-between' | 'around' | 'space-around' | 'space-evenly'
        justifyContent?: 'start' | 'flex-start' | 'center' | 'end' | 'flex-end' | 'spaced' | 'space-between' | 'around' | 'space-around' | 'space-evenly'
        alignItems?: 'start' | 'center' | 'end' | 'stretch' | 'baseline' 
        alignSelf?: 'start' | 'center' | 'end' | 'stretch' | 'baseline' 
        alignContent?: 'start' | 'flex-start' | 'center' | 'end' | 'flex-end' | 'spaced' | 'space-between' | 'around' | 'space-around' | 'stretch' 
    }
}

Steps to solve this issue

  1. I made index.d.ts in my root folder
    example:
typescript-playground
 |
 | ├── src
 | ├── public
 | ├── node_modules
 | ├── @types
 |         ├── simple-flexbox
 |                ├── index.d.ts
  1. Add "typeRoots": ["./node_modules/@types", "./@types"] in your tsconfig.json
    example:
{
  "compilerOptions": {
    "target": "es5",ue,
    "skipLibCheck": true,
    "..."
    "typeRoots": ["./node_modules/@types", "./@types"]
  },
}
  1. Copy and paste the code that I wrote above into index.d.ts .

webpack in prod dependencies

Can webpack be moved to dev-dependencies? This is causing issues in my project which uses a newer version of react

Adding <form> element as semantic element

How about adding form element as a semantic element?
It uses as a container of inputs so we should add it into our code.

 element: PropTypes.oneOf([**_'form',_** 'article', 'aside', 'div', 'figure', 'footer', 'header', 'main', 'nav', 'section'])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.