diff --git a/frontends/web/src/components/guide/entry.tsx b/frontends/web/src/components/guide/entry.tsx index fee0cff57a..a00d0c4e87 100644 --- a/frontends/web/src/components/guide/entry.tsx +++ b/frontends/web/src/components/guide/entry.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component } from 'react'; +import { FunctionComponent, useState } from 'react'; import A from '../anchor/anchor'; import style from './guide.module.css'; @@ -28,73 +28,39 @@ export interface EntryProp { } interface EntryProps { - entry: EntryProp | string; // string could be the entry translation key in cimode, e.g. 'guide.waiting.1'. + entry: EntryProp; shown?: boolean; - highlighted?: boolean; } type Props = EntryProps; -interface State { - shown: boolean; - highlighted: boolean; -} - -export class Entry extends Component { - constructor(props: Props) { - super(props); - this.state = { - shown: props.shown || props.highlighted || false, - highlighted: props.highlighted || false, - }; - } +export const Entry: FunctionComponent = props => { + const [shown, setShown] = useState(props.shown || false); - private toggle = () => { - this.setState(state => ({ - shown: !state.shown, - highlighted: false, - })); + const toggle = () => { + setShown(shown => !shown); }; - public render() { - const props = this.props; - const { - shown, - highlighted, - } = this.state; - let entry: EntryProp; - if (typeof props.entry === 'string') { - entry = { - title: props.entry + '.title', - text: props.entry + '.text', - link: { - url: props.entry + '.link.url', - text: props.entry + '.link.text', - }, - }; - } else { - entry = props.entry; - } - return ( -
-
-
{shown ? '–' : '+'}
-
-

{entry.title}

-
-
-
- {shown ? ( -
- {entry.text.trim().split('\n').map(p =>

{p}

)} - {entry.link && ( -

{entry.link.text}

- )} - {props.children} -
- ) : null} + const entry = props.entry; + return ( +
+
+
{shown ? '–' : '+'}
+
+

{entry.title}

- ); - } -} +
+ {shown ? ( +
+ {entry.text.trim().split('\n').map(p =>

{p}

)} + {entry.link && ( +

{entry.link.text}

+ )} + {props.children} +
+ ) : null} +
+
+ ); +}; diff --git a/frontends/web/src/components/guide/guide.module.css b/frontends/web/src/components/guide/guide.module.css index d382df2360..cece2584b4 100644 --- a/frontends/web/src/components/guide/guide.module.css +++ b/frontends/web/src/components/guide/guide.module.css @@ -88,12 +88,6 @@ margin-top: var(--space-default); } -.highlighted { - margin: 1.1em -1em; - padding: 0.5em 1em; - background-color: var(--color-darkblue); -} - .entryTitle { display: flex; flex-direction: row; @@ -151,7 +145,7 @@ transform: translateX(100%); transition-delay: 0.2s; } - + .show { opacity: 1; z-index: 4002;