microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/html-program-viewer/src/common.tsx
71lines · modecode
| 1 | import React, { FunctionComponent, PropsWithChildren } from "react"; |
| 2 | import _styled from "styled-components"; |
| 3 | export const styled = typeof _styled === "function" ? _styled : (_styled as any).default; |
| 4 | |
| 5 | export interface SectionProps { |
| 6 | title: string; |
| 7 | id?: string; |
| 8 | hide?: boolean; |
| 9 | } |
| 10 | |
| 11 | const SectionDiv = styled.div` |
| 12 | border: 1px solid #c5c5c5; |
| 13 | `; |
| 14 | const SectionTitle = styled.div` |
| 15 | border-bottom: 1px solid #c5c5c5; |
| 16 | background-color: #4875ca; |
| 17 | color: #f5f5f5; |
| 18 | padding: 2px 5px; |
| 19 | `; |
| 20 | const SectionContent = styled.div` |
| 21 | padding: 1rem; |
| 22 | `; |
| 23 | export const Section: FunctionComponent<PropsWithChildren<SectionProps>> = ({ |
| 24 | id, |
| 25 | title, |
| 26 | hide, |
| 27 | children, |
| 28 | }) => { |
| 29 | if (hide) { |
| 30 | return <div></div>; |
| 31 | } |
| 32 | return ( |
| 33 | <SectionDiv id={id}> |
| 34 | <SectionTitle>{title}</SectionTitle> |
| 35 | <SectionContent>{children}</SectionContent> |
| 36 | </SectionDiv> |
| 37 | ); |
| 38 | }; |
| 39 | |
| 40 | const ItemDiv = styled.div` |
| 41 | border: 1px solid #c5c5c5; |
| 42 | `; |
| 43 | const ItemTitle = styled.div` |
| 44 | border-bottom: 1px solid #c5c5c5; |
| 45 | background-color: #dedede; |
| 46 | padding: 2px 5px; |
| 47 | `; |
| 48 | const ItemContent = styled.div` |
| 49 | padding: 1rem; |
| 50 | `; |
| 51 | export const Item: FunctionComponent<PropsWithChildren<SectionProps>> = ({ |
| 52 | id, |
| 53 | title, |
| 54 | hide, |
| 55 | children, |
| 56 | }) => { |
| 57 | if (hide) { |
| 58 | return <div></div>; |
| 59 | } |
| 60 | return ( |
| 61 | <ItemDiv id={id}> |
| 62 | <ItemTitle>{title}</ItemTitle> |
| 63 | <ItemContent>{children}</ItemContent> |
| 64 | </ItemDiv> |
| 65 | ); |
| 66 | }; |
| 67 | |
| 68 | export const Literal = styled.div` |
| 69 | color: #5da713; |
| 70 | display: inline; |
| 71 | `; |
| 72 | |