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

Attempt to revise <TextLabel> (pt. 1) #5

Merged
merged 11 commits into from
Mar 20, 2017

Conversation

zhusee2
Copy link
Contributor

@zhusee2 zhusee2 commented Mar 15, 2017

Purpose

Try to simplify the underlying structure of <TextLabel>, starting with replacing <TextLayout> with <Text>.

My current plan is:

  1. Stop using <TextLabel> inside almost every component.
    Previous experiences have shown such usage results in a huge, complex mega component with too many features.

  2. Compose every base component using <Icon> and <Text>

Components

<Text> (proposed to replace <TextLayout>)
<BasicRow> (stays under Text/, not exposed.)

Usage

<Text
    aside="Aside text"
    align="center"
    basicRow={null} // see desc below
    basic="Basic text" // consumed by <BasicRow>
    tag="Tag"  // consumed by <BasicRow>
    stateIcon={<StatusIcon status="loading" />}  // consumed by <BasicRow>
/>

The row for basic text can be replace via basicRow prop.

In some cases like <TextInput> it can replace the whole row with a general <input> so it should be able to take up full-width.

DOM output

Output of current implement of <Text>

<div class="ic-text ic-text--center">
    <div class="ic-text__row ic-text__basic">
        <div class="ic-flex-cell" style="flex: 0 1 auto;">
            <div class="ic-text-ellipsis">Basic Text</div>
        </div>
        <span class="ic-tag">Tag</span>
        <span class="ic-status-icon ic-status-icon--inline">
            <span
                class="ic-icon ic-icon--blue ic-icon-inline-success"
                role="presentation">
            </span>
        </span>
    </div>
    <div class="ic-text__row ic-text__aside">I am center-aligned</div>
</div>

while the previous output of <TextLayout> in iC-framework-react:

<div class="ic-text-layout ic-text-layout--center">
    <div class="ic-text-layout__body">
        <div class="ic-text-layout__basic">
            <div class="ic-flex-layout ic-flex-layout--center">
                <div class="ic-flex-cell ic-flex-cell--shrink">
                    <div class="ic-text-ellipsis">Basic Text</div>
                </div>
                <div class="ic-flex-cell">
                    <span class="ic-tag">Tag</span>
                </div>
                <div class="ic-flex-cell">
                    <i class="ic-icon ic-icon--blue ic-icon-inline-success"></i>
                </div>
            </div>
        </div>
        <div class="ic-text-layout__aside">Aside Text</div>
    </div>
</div>

Dependency

#4

@zhusee2 zhusee2 requested a review from cjies March 15, 2017 11:24
@zhusee2 zhusee2 force-pushed the feature/zhusee_revise_text_label branch from a8e6f97 to 6f86a22 Compare March 16, 2017 06:34
@zhusee2 zhusee2 changed the base branch from feature/zhusee_migrate_1st_batch to develop March 17, 2017 05:58
Copy link
Contributor

@cjies cjies left a comment

Choose a reason for hiding this comment

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

Others LGTM 👍

import Tag from '../Tag';
import TextEllipsis from '../TextEllipsis';

function wrapIfNotElement(content, { with: Wrapper }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can add some simple description to describe how this method works?
Since I cannot understand this method straightly from it's name XD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I'll add comments XD

But basically it's a function to check: if the passed-in content is not a valid React Element, then wrap it with Wrapper. Otherwise just return the content.

@zhusee2 zhusee2 force-pushed the feature/zhusee_revise_text_label branch from 6f86a22 to aa10cda Compare March 20, 2017 07:30
@zhusee2
Copy link
Contributor Author

zhusee2 commented Mar 20, 2017

@cjies I've added the comments as suggested, and I also added some tests to the new components introduced in this PR. Please help take a look again.

Here's the diffs: 842e0c5...aa10cda

@zhusee2 zhusee2 merged commit acadde2 into develop Mar 20, 2017
@zhusee2 zhusee2 deleted the feature/zhusee_revise_text_label branch March 20, 2017 08:31
@zhusee2 zhusee2 mentioned this pull request May 24, 2017
18 tasks
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.

2 participants