Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Add LevelIndicator component #55

Merged
merged 5 commits into from
Sep 5, 2018
Merged

Add LevelIndicator component #55

merged 5 commits into from
Sep 5, 2018

Conversation

colleenmcginnis
Copy link
Contributor

@colleenmcginnis colleenmcginnis commented Sep 4, 2018

This PR does two things:

1️⃣ Adds a new LevelIndicator component based on the work done in /help (ty @danswick).

image

2️⃣ Adds optional level and language props to Card (to be used for /help tutorials).

image

Closes #53

Copy link
Contributor

@davidtheclark davidtheclark left a comment

Choose a reason for hiding this comment

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

Awesome component composition thinking here.

title: 'This is a full-length title',
path: 'url',
description: "Here's a reasonable length for a description.",
level: <LevelIndicator level={2} />,
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 one possibility for the interface; another would be to pass the level number directly. Curious why you chose to pass a React element instead of the level number? Do you think we may want to pass some other element in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea it's probably safe to just pass the level number.

let squareColor = '';
num > this.props.level
? (squareColor = 'gray-light')
: (squareColor = levelColor);
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be combined into one expression:

const squareColor = num > props.level ? 'gray-light' : levelColor;

className={`inline-block w6 bg-${squareColor} align-middle mr3`}
/>
);
});
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 great use case for .map()! When you're taking one array (which should probably be Object.keys(levels)?) and transforming every item into another corresponding item in a new array (e.g. a React element), .map() is what you're looking for.

@colleenmcginnis colleenmcginnis merged commit a0506ea into master Sep 5, 2018
@colleenmcginnis colleenmcginnis deleted the difficulty-level branch September 5, 2018 00:52
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.

2 participants