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

Update cf-component-label to use Fela #103

Merged
merged 7 commits into from
Apr 18, 2017
Merged

Conversation

manatarms
Copy link
Contributor

Creating this PR because I had done it. We can merge whenever we decide to.

@manatarms
Copy link
Contributor Author

manatarms commented Mar 17, 2017

As a reminder Do Not Merge till we start merging Fela components.

@manatarms manatarms mentioned this pull request Mar 17, 2017
33 tasks
@tajo
Copy link
Contributor

tajo commented Mar 17, 2017

please rebase

@manatarms
Copy link
Contributor Author

@tajo This is good to go. You can merge this and publish into cf-ux when you're ready.

@jwineman
Copy link
Contributor

If @tajo approves lets merge and have him release.

I'm hesitant to release since I haven't been following the issues as closely recently.

@sejoker sejoker self-requested a review March 22, 2017 18:36
@tajo
Copy link
Contributor

tajo commented Mar 22, 2017

Question: Are these styles using our private styles?

import Label from 'cf-component-label';
import felaTestContext from '../../../styleguide/felaTestContext';
import { applyTheme } from 'cf-style-container';
import { Label as LabelUnstyled, LabelTheme } from 'cf-component-label';
Copy link
Contributor

Choose a reason for hiding this comment

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

please, use relative paths... this will break once this is merged: #101

const styles = props => {
const theme = props.theme;
return {
display: theme.display,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these styles based on stas/www-next/styles/src/components/label.css ?

.cf-label {
  display: inline-block;
  padding: $cf-label-padding;
  font-size: $cf-label-font-size;
  line-height: $cf-label-line-height;
  vertical-align: baseline;
  white-space: nowrap;
  color: $cf-label-color;
  font-weight: $cf-weight-semi-bold;
  text-transform: uppercase;
  -webkit-text-stroke: 0;
  border-radius: $cf-label-border-radius;
  user-select: none;
}

.cf-label--default {
  background: $cf-label-default;
}

.cf-label--info {
  background: $cf-label-info;
}

.cf-label--success {
  background: $cf-label-success;
}

.cf-label--warning {
  background: $cf-label-warning;
}

.cf-label--error {
  background: $cf-label-error;
}

It seems that's not the case (you used public styles.css?). We are not going to main styles.css anymore. cf-ui/cf-component-label should be identical to labels that you can find on cloudflare.com. Can you please update. The difference isn't big.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the public styles, this was before we decided to have a singular style sheet. I'll put in our private styles.

import { checkBaseTheme } from 'cf-style-const';

export default baseTheme => {
checkBaseTheme(baseTheme, 'ButtonTheme');
Copy link
Contributor

Choose a reason for hiding this comment

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

LabelTheme

import { applyTheme } from 'cf-style-container';
import { Label as LabelUnstyled, LabelTheme } from 'cf-component-label';

const Label = applyTheme(LabelUnstyled, LabelTheme);
Copy link
Contributor

Choose a reason for hiding this comment

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

We now export styled components by default. So this should go into ./src/index.js and you should

export { Label, LabelUnstyled, LabelTheme }

@manatarms
Copy link
Contributor Author

manatarms commented Apr 3, 2017

Should I still make these changes in this PR? Or open a new one with the updated migration changes?

Copy link
Contributor

@wyuenho wyuenho left a comment

Choose a reason for hiding this comment

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

Convert this back to ES6 classes please. We'll need the occasional ref, and functional components isn't actually faster.

@wyuenho
Copy link
Contributor

wyuenho commented Apr 3, 2017

@manatarms Just fix this PR.

@sejoker
Copy link
Contributor

sejoker commented Apr 4, 2017

@wyuenho I disagree with migrating to ES6 format simply because of future requirements. The idea to use functional components is solely due to simpler mental model not because of speed benefits. IMO, the author who will need use of refs will convert to ES6 easily.

@wyuenho
Copy link
Contributor

wyuenho commented Apr 4, 2017

the author who will need use of refs will convert to ES6 easily.

@sejoker I don't want to see any inconsistency. Needing refs is not a future requirement, it's a requirement now. This is probably something that should have gone into the discussions but didn't. We've talked about this about this time last year. No regression please, functional components don't buy us much now.

@manatarms
Copy link
Contributor Author

Please look at this so I can merge it. I've made all the changes as per the discussion #162

@@ -10,6 +10,10 @@
"publishConfig": {
"registry": "http://registry.npmjs.org/"
},
"dependencies": {
"cf-style-container": "^1.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to change these manually. Lerna would handle this during the release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove these? Or let them be?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can leave it.


class Label extends React.Component {
render() {
return React.createElement(
this.props.tagName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we changing the API? We use spans everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is because I checked our codebase and the only implementation is using span. This also breaks our pattern of having a standardized component, a user could technically render anything using the tagName.

Copy link
Contributor

Choose a reason for hiding this comment

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

in the same way className leaks style this was leaking DOM (lol?). If we actually need to switch the underlying HTML tag we should expose it as an enumerated prop not a free form string.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok


export default baseTheme => {
return {
borderRadius: baseTheme.borderRadius,
Copy link
Contributor

Choose a reason for hiding this comment

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

4 spaces? should be 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah man. Prettier defaults to 4.

Copy link
Contributor

Choose a reason for hiding this comment

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

No code style code review comments! Prettier is god.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@manatarms
Copy link
Contributor Author

@wyuenho If this looks okay to you can we merge it?

@manatarms manatarms merged commit f97cb4c into master Apr 18, 2017
@manatarms manatarms deleted the fela-component-label branch April 18, 2017 21:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants