Guest User

Untitled

a guest
Jul 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. let HelpTextBody = function(props: { helpDocument: DocumentationStore }) {
  2. return (
  3. <div>
  4. {props.helpDocument.toReallySimple().map(tok => {
  5. return React.createElement(tok.tag, null, tok.content);
  6. })}
  7. </div>
  8. );
  9. };
  10.  
  11. toReallySimple(): MdJson[] {
  12. let bigParsed = this.md_.parse(this.Text, null).filter(
  13. t => return t.type == "inline" || t.type.indexOf("open") > 0
  14. });
  15.  
  16. const StyledHelpDocument = styled(HelpTextBody)`
  17. background-color: lightslategray;
  18. `;
  19.  
  20. class HelpText extends React.Component<helpProps, helpState> {
  21. constructor(props: helpProps) {
  22. super(props);
  23. this.state = {
  24. hidden: true
  25. };
  26. }
  27.  
  28. swapHidden() {
  29. this.setState({
  30. hidden: !this.state.hidden
  31. });
  32. }
  33.  
  34. render() {
  35. if (this.state.hidden) {
  36. return (
  37. <span>
  38. <StyledButton
  39. itemScope={this.state.hidden}
  40. onClick={() => this.swapHidden()}
  41. >
  42. Need Help?
  43. </StyledButton>
  44. </span>
  45. );
  46. } else {
  47. return (
  48. <span>
  49. <StyledButton onClick={() => this.swapHidden()}>
  50. Hide Help
  51. </StyledButton>
  52. <StyledHelpDocument helpDocument={this.props.helpDocument} />
  53. </span>
  54. );
  55. }
  56. }
  57.  
  58. <style data-styled-components="">
  59. /* sc-component-id: sc-bdVaJa */
  60. .sc-bdVaJa {} .gscXTZ{background:red;color:white;font-size:1em;margin:1em;padding:0.25em 1em;border:2px solid red;border-radius:3px;}.iwtdKP{background:white;color:red;font-size:1em;margin:1em;padding:0.25em 1em;border:2px solid red;border-radius:3px;}
  61. /* sc-component-id: sc-bwzfXH */
  62. .sc-bwzfXH {} .hAvMqj{background-color:lightslategray;}</style>
  63.  
  64. <span>
  65. <button class="sc-bdVaJa iwtdKP">Hide Help</button>
  66. <div><p>Here the text is grey</p></div>
  67. <!-- ^This^ is the StyledHelpDocument... no class!-->
  68. </span>
Add Comment
Please, Sign In to add comment