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

Add Statistic and Statistics components #117

Merged
merged 8 commits into from
Nov 24, 2015
Merged

Conversation

levithomason
Copy link
Member

From here: http://semantic-ui.com/views/statistic.html

Our doc site rendering with code example:

image

return (
<div>
<StatisticTypesExamples />
</div>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single basic example, just to prove the component. Extended examples can be added on a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the <div> here?

@@ -0,0 +1,24 @@
import React, {Component} from 'react';
import {Statistic} from 'stardust';
const {Statistics, Label, Value} = Statistic;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have spec'd to restructure to sub-components as static properties on the parent component, see #99. Up until now this has only included component parts, or elements internal to the component. For instance, a <Menu.Item /> for a <Menu />.

This PR proposes (shown on ln 3) that we also include the plural "group" element as a sub-component.

Pros:

  • Only a single property (parent component) needs to be exposed in the Stardust module.
  • Only a single import is required to use the full spectrum of markup for a given component. Opposed to importing the component and it's plural name for groups, as it is currently.
  • I think it is the proper cohesion as you should never use <Items /> unless you are also using <Item />.

Cons:

  • The naming is a little odd and ugly (note I destructured the sub-components above). This is especially true with longer component names and without destructuring:

    <Statistic.Statistics>
    <Statistic>
      <Statistic.Value>22</Statistic.Value>
      <Statistic.Label>Faves</Statistic.Label>
    </Statistic>
    <Statistic>
      <Statistic.Value>31,200</Statistic.Value>
      <Statistic.Label>Views</Statistic.Label>
    </Statistic>
    </Statistic.Statistics>

Ideas:

  • We could use the sub-component name Group for the plural names. It would give us a standard across all components and slightly clearer syntax (below). However, it does break the alignment with JS class names and HTML class names (className='statistics' and class Group extends Component {...). Also, we'd further obfuscate parity with Semantic UI.

    <Statistic.Group>
    <Statistic>
      <Statistic.Value>22</Statistic.Value>
      <Statistic.Label>Faves</Statistic.Label>
    </Statistic>
    <Statistic>
      <Statistic.Value>31,200</Statistic.Value>
      <Statistic.Label>Views</Statistic.Label>
    </Statistic>
    </Statistic.Group>

Feedback?

@@ -0,0 +1,24 @@
import React, {Component} from 'react';
import {Statistic} from 'stardust';
const {Statistics, Label, Value} = Statistic;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to repost this comment as it became outdated due a new push.


We have spec'd to restructure to sub-components as static properties on the parent component, see #99. Up until now this has only included component parts, or elements internal to the component. For instance, a <Menu.Item /> for a <Menu />.

This PR proposes (shown on ln 3) that we also include the plural "group" element as a sub-component.

Pros:

  • Only a single property (parent component) needs to be exposed in the Stardust module.
  • Only a single import is required to use the full spectrum of markup for a given component. Opposed to importing the component and it's plural name for groups, as it is currently.
  • I think it is the proper cohesion as you should never use <Items /> unless you are also using <Item />.

Cons:

  • The naming is a little odd and ugly (note I destructured the sub-components above). This is especially true with longer component names and without destructuring:

    <Statistic.Statistics>
    <Statistic>
      <Statistic.Value>22</Statistic.Value>
      <Statistic.Label>Faves</Statistic.Label>
    </Statistic>
    <Statistic>
      <Statistic.Value>31,200</Statistic.Value>
      <Statistic.Label>Views</Statistic.Label>
    </Statistic>
    </Statistic.Statistics>

Ideas:

  • We could use the sub-component name Group for the plural names. It would give us a standard across all components and slightly clearer syntax (below). However, it does break the alignment with JS class names and HTML class names (className='statistics' and class Group extends Component {...). Also, we'd further obfuscate parity with Semantic UI.

    <Statistic.Group>
    <Statistic>
      <Statistic.Value>22</Statistic.Value>
      <Statistic.Label>Faves</Statistic.Label>
    </Statistic>
    <Statistic>
      <Statistic.Value>31,200</Statistic.Value>
      <Statistic.Label>Views</Statistic.Label>
    </Statistic>
    </Statistic.Group>

Feedback?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this change the syntax for all components that have sub-components? Or just those that need to have "groups" for styling?

I could see using the Group sub-component name with Statistics and Segments but how would this look for other components such as Menu and List?

I have seen benefits in developing with aligning JS class names and HTML class names while developing with Stardust components, in that I could easily look through the semantic ui docs and make accurate guesses on how the component is named, but I do agree <Statistic.Statistics> does not feel as intuitive as <Statistic.Group>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would only affect the group sub-component. I think for now then we'll keep parity with the class names, sd-statistic-statistics inside <Statistic.Group /> and also, the Semantic UI doc site. If we feel otherwise later we can refactor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit overwhelming to look at. I think I would rather see <Statistic value="22" label="Faves" /> but I realize the .Value, etc provides good options

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue there was, the label can be on top or on bottom. So we had to either make a topLabel and bottomLabel prop (and probably a label prop that defaulted to top). Or, go our sub-component approach. Knowing this, is your preference the same?

@kyleturco
Copy link
Contributor

What's the urgency on this one? I can try to build out the rest of the examples tomorrow to include in this PR

@athurman
Copy link
Contributor

🌊 🐙

levithomason added a commit that referenced this pull request Nov 24, 2015
Add Statistic and Statistics components
@levithomason levithomason merged commit b4a4df5 into master Nov 24, 2015
@levithomason levithomason deleted the feature/statistic branch November 24, 2015 15:18
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

Successfully merging this pull request may close these issues.

3 participants