GithubHelp home page GithubHelp logo

semantic-org / semantic-ui-react Goto Github PK

View Code? Open in Web Editor NEW
13.2K 216.0 4.0K 201.47 MB

The official Semantic-UI-React integration

Home Page: https://react.semantic-ui.com

License: MIT License

JavaScript 99.89% TypeScript 0.11%
react semantic-ui component-library components javascript-libraries javascript-library frontend-framework frontend-components react-components react-library js-library

semantic-ui-react's Introduction

Gitter Circle Codecov David npm

Installation & Usage

See the Documentation for an introduction, usage information, and examples.

Built With

  • Amazon Publishing โ€” the full-service publisher of Amazon โ€” APub.com
  • Netflix's Edge Developer Experience team's numerous internal apps
  • Netflix's flamescope
  • Microsoft's Teams prototyping

Example Projects

This is a listing of example projects and guides that will help you integrate Semantic UI React into your new or existing projects.

Show projects

Semantic UI React implementation of react-redux Todo List.

FAQ

Can I use custom Icons? Yes. Just use <Icon className='my-icon' /> instead of <Icon name='my-icon' />. See #931 (comment) for detailed info and examples.
How do I setup CSS?

There are several options. Refer to our doc on CSS Usage.

Can I use a custom CSS theme? Yes. Semantic UI React includes components that render valid Semantic UI HTML, no CSS is included. This allows you to load any Semantic UI CSS theme on top of your Semantic UI React app.

Here are some helpful links:

How Can I Help?

Help shape this library by weighing in on our RFC (request for comments) issues.

Our CONTRIBUTING.md is a step-by-step setup and development guide.

Issues labeled good first issue are a great way to ease into development on this project.

We're seeking component parity with Semantic UI, plus some addons. There is an issue for every missing component, labeled new component. Just comment on the issue you'd like to take.

Any other issue labeled help wanted is ready for a PR.

Principles

  • No animation dependencies
  • Simple declarative component APIs vs brittle HTML markup
  • Complete keyboard support
  • Complete SUI component definition support
  • Completely documented
  • Completely tested
  • Accessible

Credit

Created by @levithomason and an amazing community of contributors.

Made possible only by @jlukic authoring Semantic UI.

Blazing deployments by Vercel.

semantic-ui-react's People

Contributors

aabustamante avatar athurman avatar ayastreb avatar deweybot avatar dpkwhan avatar dylankiss avatar eanplatter avatar fabianopb avatar fracmak avatar gitname avatar greenkeeperio-bot avatar grumblerchester avatar iamcaleberic avatar jeffcarbs avatar jhchill666 avatar jongsue avatar josie11 avatar kamdz avatar koenvg avatar kyleturco avatar layershifter avatar levithomason avatar mihai-dinculescu avatar noinkling avatar patrikmolsson avatar pierre-h avatar tadeploy avatar tarang9211 avatar unbrandedtech avatar xiaohanyu 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  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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

semantic-ui-react's Issues

Spread unhandled props on the root element

The issue I am running across, is when passing a style object into the Checkbox component, it acts as it should and applies styles to the actual checkbox input, yet I need the styles to be attributed to the parent 'ui checkbox' div in order to get it to float right as needed.

Here is a screen shot of how the custom styled checkbox renders:
screen shot 2015-10-25 at 2 14 43 pm

Because the style shows on the input, and not the parent semantic div, the entire checkbox semantic element does not float right as it should.

Here is a screenshot of the rendered markup:
screen shot 2015-10-25 at 2 15 37 pm

DATEPICKER

Doesn't currently exist in semantic at all. We need them to change graph scopes on FA

Right side width

The right side (content not left menu) doesn't have a responsive width. Below 1400px or so, the content goes out of the right side of the browser. It should respond to window size.

Static meta info object

If we add some kind of static _meta data object to the components it would make many things easier and our generated docs and tests more declarative. It would be an object containing type, name, and parent which would allow classifying the component declaratively. Example, a <Field /> would have a _meta as follows:

static _meta = {
  type: 'collection',
  name: 'field',
  parent: 'form'
};

This component is organized in Semantic UI as a "collection". It is not a top level component, but part of the "Form". The class name and filename should already be named Field by convention. This gives a declarative place it can be found. We can use this for generated documentation, testing, and for #69 spreadable props util.

Docs Use
The docs would use it to organize the menu, examples, generate links to Semantic's docs, and determine when to deep link to things like plugin settings (if the component is a "module").

Tests Use
Conformance test would use it to determine which standards this component should comply with. Example, if the component is a module, ensure the settings prop was not spread.

Util Use
propsUtil.getSpreadableProps() would use it to determine if the settings prop should be removed or not.

Use cases would continue to grow I'm sure.

EDIT
Speaking of which, we have some components that are not included in Semantic. Like the Confirm component. These are of type addon currently.

static _meta = {
  type: 'addon',
  name: 'confirm',
  parent: null
};

Using this, we can determine if a component is a Semantic component or a Stardust component. Even better, we may just add a isSemanticUIComponent key. This will be useful for things like #71 #72, conformance testing.

Select Input Needs to be Controlled Component

Currently, the Select element does not take in a name Proptype, and therefore when used in a Form component, renders the serialized JSON key for that specific input as null.

Also, the select element needs to have a handleChange() function to make it a controlled component.

Example display order

On the doc page the examples are displaying in alphabetical order based on file name. Ideally, we could control the display order. That way we can display new elements in logical/sequential order.

Nesting an <Input /> in a <Field />

When nesting a Stardust <Input /> in a <Field />, extra markup is generated.

Semantic field markup consists of a field div around an input:

<div class="ui form">
  <div class="field">
    <label>User Input</label>
    <input type="text">
  </div>
</div>

Semantic input markup consists of a ui input div around an input:

<div class="ui input">
  <input type="text" placeholder="Search...">
</div>

There is never more than one div wrapping an input. The div is either a field div or a ui input div.

Since Stardust <Field /> and <Input /> components both have an outer div with their respective Semantic classes (field and ui input) we get two divs wrapping the input when we nest them like so:

<div class="ui form">
  <div class="field">
    <label>User Input</label>
    <div class="ui input">
      <input type="text" placeholder="Search...">
    </div>
  </div>
</div>

With limited examples at tests at the moment, it is not clear if this is a real issue. Though, it is improper use of the framework and we should find a solve for it.

Conformance test for element and plugin

Semantic Modules each have a plugin. We expose this plugin at this.element.<pluginName> which is the component name. The element is the jquery element. We should test that both the element and the plugin are exposed.

Also, we should test that the plugin is called on componentDidMount, and that this.element.off() is called on componentWillUnmount.

To do this, we should certainly add the meta info in #70 so that we can determine if this is a Semantic component and if it is a module.

Before embarking on implementing this functionality in all components, consider a decorator that adds this boiler plate.

Cleanup redundancy in tests

There is a lot of redundancy in tests. Mostly, findFoo() calls serve both query and assertion purposes. These are equivalent:

let gridClassName = render(<Grid />).findClass('sd-grid').props.className;
gridClassName.should.contain('sd-grid');
render(<Grid />).findClass('sd-grid');

Update all tests to remove their redundant assertions.

Replace class usage with attributes.

Button

- [ ] fluid - [ ] colors (all semantic colors) - [ ] size (all semantic sizes)

Image

- [ ] fluid - [ ] rounded - [ ] circular - [ ] ["top aligned", "middle aligned", "bottom alignded"] - [ ] size - [ ] centered - [ ] bordered - [ ]

Button warning

I get this warning:
screen shot 2015-10-05 at 5 31 09 pm

when running this code:

<Button className='icon ui fluid inverted button'>
  Earnings
  <i className='dropdown icon' />
</Button>

Remove bluebird dependency

Currently, the Modal is the only component depending on bluebird. It would be nice to not have an extra dependency for just one component. Explore other options.

Input does not handle labels

Though the Stardust Input API may be different than what was attempted below, we should be handling this functionality.

image

Floated examples break the docs code layout

This can be easily circumvented if the code snippet were in its own column. There should also be some more padding between examples. We should toss that in this fix as well.

image

getSpreadableProps util

A util for getting spreadable props, to handle this use case:

let checkboxProps = _.clone(this.props);
delete checkboxProps.settings;  // all modules need to do this
delete checkboxProps.className; // this would be passed in

// then

<input {...checkboxProps} />

We need to remove props.settings from all Semantic UI Modules. Also, many components need to exclude certain props from being spread as they belong elsewhere. Like the checkbox example above, and this message example:

let messageProps = _.clone(this.props);
delete messageProps.icon;

// then

<div {...messageProps}>

The icon prop belongs as classes on the icon inside the message, then the rest of the props are spread.

This should be abstracted away with a util that understands what to do to get spreadable props.

Create attached button element

We want to be able to use a Button element attached a div. Currently, when set as a Button it doesn't adopt the styling of the attached div. See PR #45

Need Generic Select Component

This is separate from creating a semantic ui specific [Dropdown]ttp://semantic-ui.com/modules/dropdown.html).

What is needed is a simple Select component that is a select input type to be used in forms. Please note it will also specifically need a multiple prop that will allow you to choose multiple inputs if needed. Code example below:

import React, {Component, PropTypes} from 'react';

class Select extends Component {
  static propTypes = {
    label: PropTypes.string,
    multiple: PropTypes.bool,
    options: PropTypes.array,
    value: PropTypes.oneOfType([
      React.PropTypes.string,
      React.PropTypes.array,
    ]),
  };

  render() {
    let options = this.props.options.map((opt, i) => {
      return <option key={i} value={opt.value}>{opt.text}</option>;
    });
    let value = _.isEmpty(this.props.value) ? '' : this.props.value;
    return (
      <div>
        <select {...this.props} className='sd-select ui fluid dropdown' value={value} multiple={this.props.multiple}>
          {options}
        </select>
      </div>
    );
  }
}

export default Select;

ListItem updates and fixes

Icon Prop

  • define propTypes for string and instanceOf i (will be </Icon /> when merged)
  • if a string, construct an <Icon /> with the string as classes
  • otherwise, render as is

Image Prop

  • define propTypes for string and instanceOf <Image />
  • if a string, construct a <Image className='avatar' /> with the string as the src
  • otherwise, render as is

Description and children

  • Allow a description prop to defined and children. Currently, children override the description in render which breaks nested lists.

Cleanup

  • use getUnhandledProps util instead of cloning and deleting prop keys (example in Checkbox).
  • do not _.clone() props for no reason, just use the prop directly.
  • do not const foo = this.props.foo for no reason, just use the prop directly.

Examples

  • update examples to use new icon/image prop capabilities

    For brevity, I think we should use faker and the image string option for all examples: <ListItem image={faker.internet.avatar()} />. Then, just show one near the top that shows you can also pass in an image element. This way, there aren't so many examples that import and construct images to show the list.

  • update nested list example, removing the extra div (fixed by children/description task above)

Use local modules in dev

User bower components during dev for faster reloads. import $ from 'jquery' should be a webpack'd to the bower component.

Use cdn's in production.

CustomPropTypes util

As mentioned in #65 we should start a custom prop type util:

  • mutually exclusive prop type:

    // warn if "description" and any of these others are defined
    description: customPropTypes.mutuallyExclusive(['children'])

Do Inline Fields Work?

I wanted to do something like this:
screen shot 2015-10-26 at 5 48 29 pm

With syntax like this:

<Field
  width={8}
  label='Name'
  className='inline'
>
<Input
  placeholder='First Name'
  onChange={this.handleChange}
  value={this.state.user.firstName}
/>

but I got this:
screen shot 2015-10-26 at 5 52 20 pm

Is my syntax off or is this a real issue?

Set value instead of object for serializing Form data

current method of serializing.

        switch (node.getAttribute('type')) {
          case 'checkbox':
            json[name] = {checked: node.checked};
            break;

          case 'radio':
            json[name] = {
              value: _.find(arr, {name: name, checked: true}).value
            };
            break;

          default:
            json[name] = {value: node.value};
            break;
        }

Conformance test for children/description/text props

Some components will take a description or text prop. These props may also be defined using children.

In the case where children and another conflicting prop is defined, the children prop should win. We should be able to test if the current component is a Semantic component (see #70), and if it has a description/test prop, then test that the children prop wins if both are defined.

Restructure sub components

Currently there is one flat level of components in stardust, Modal, ModalFooter, etc. This is leading to confusion for some components (List, ListItem, Item). Refactor to use the format suggested by the React docs.

import {List, Table, Menu} from 'stardust';

const list = (
  <List>
    <List.Item />
  </List>
);

const table = (
  <Table>
    <Table.Column />
  </Table>
);

const menu = (
  <Menu>
    <Menu.Item />
  </Menu>
);

This will also remove the need for the parent key in the _meta description as the relationship will be declarative. Generating the nested doc menu will be a breeze as well.

Drop /dist build

This is currently broken and not required. The src is better since webpack can optimize it when the user imports it.

Tests for customPropType utility

Need to make sure and test the functionality of the mutuallyExclusive function within customPropType.js utility to expect it to throw an error if two props that are mutually exclusive exist together.

Duplicate random data causing intermittent Table test fail

The table column test ensures there are no columns present for the TableColumn that was removed from the table definition. However, sometimes, there are two columns with the same name generated. Removing one, and testing that all are not present fails.

Instead, get a unique list of table columns before continuing.

image

In table test:

  describe('row', () => {
    it('only contains cells that were defined in TableColumns', () => {
      render(
        <Table data={tableData}>
          <TableColumn dataKey={randomDataKey} />
        </Table>
      )
...

Component guideline test

There should be a test that ensures a component adheres to the guidelines. We should then loop through all the components on stardust and run the test against them.


Tests

  • className is inherited.
  • If the underlying class name follows ui <component> format, className is inherited between ui and <component.
  • If the underlying class name does not include ui, className is inherited before the component class. Example, fields only have a field class, inheritance is <className> field.
  • props are spread on the underlying element.

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.