-
Notifications
You must be signed in to change notification settings - Fork 352
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
[Numeric Input] - Show "Format Options" Tooltip as List #1861
base: main
Are you sure you want to change the base?
Changes from 9 commits
dd182db
ee74650
81ab282
2b1c4dd
1b60da4
efc1e6a
886e67a
860e56b
7a6b4e7
5ae985c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus": patch | ||
--- | ||
|
||
[Numeric Input] - Show format options as a list |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,9 +146,18 @@ class InputWithExamples extends React.Component<Props, State> { | |
render(): React.ReactNode { | ||
const input = this._renderInput(); | ||
|
||
const examplesContent = _.map(this.props.examples, (example) => { | ||
return "- " + example; | ||
}).join("\n"); | ||
const examplesContent = | ||
this.props.examples.length <= 2 | ||
? this.props.examples.join(" ") // A single item (with or without leading text) is not a "list" | ||
: this.props.examples // 2 or more items should display as a list | ||
.map((example, index) => { | ||
// If the first example is bold, then it is most likely a heading/leading text. | ||
// So, it shouldn't be part of the list. | ||
return index === 0 && example.startsWith("**") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the plan. We have follow-up tickets to refactor aspects of Numeric Input. Seeing as how |
||
? `${example}\n` | ||
: `- ${example}`; | ||
}) | ||
.join("\n"); | ||
|
||
const showExamples = | ||
this.props.shouldShowExamples && this.state.showExamples; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -541,24 +541,20 @@ | |
} | ||
} | ||
|
||
// TODO(joel) - remove? | ||
.perseus-tooltip { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This style wasn't really used, other than to be a base later on in |
||
.perseus-formats-tooltip { | ||
background: #fff; | ||
color: #777; | ||
padding: 5px 10px; | ||
width: 240px; | ||
} | ||
|
||
// CSS is evil; let's overwrite some styles. T_T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No! CSS is not evil. Misunderstood, maybe. But definitely not evil. |
||
.perseus-formats-tooltip { | ||
.perseus-tooltip; | ||
color: #777; | ||
} | ||
.framework-perseus .perseus-formats-tooltip .paragraph > ul { | ||
padding: 0; | ||
margin: -20px 0 -16px 0; | ||
> li { | ||
list-style-type: none; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no evidence that this was ever needed. A list should (almost) always look like a list. |
||
/* | ||
Extra specificity needed to override other styles that are too broad. | ||
Once we get a better framework in place (like CSS Modules), we can fix this selector. | ||
*/ | ||
.framework-perseus .perseus-formats-tooltip .paragraph, | ||
.framework-perseus .tooltipContainer .perseus-formats-tooltip .paragraph ul { | ||
margin: 0; | ||
} | ||
|
||
.box-shadow(@shadow: 0 1px 3px rgba(0,0,0,0.25)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this
data-perseus-paragraph-index
attribute? Is it like our version oftabIndex
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question has been posted to the team.