|
| 1 | +import { component, mixin, createCell, Fragment } from 'web-cell'; |
| 2 | +import classNames from 'classnames'; |
| 3 | +import { ReposListForOrgResponseData } from '@octokit/types'; |
| 4 | + |
| 5 | +import { NavBar } from 'boot-cell/source/Navigator/NavBar'; |
| 6 | +import { Form } from 'boot-cell/source/Form/Form'; |
| 7 | +import { Field } from 'boot-cell/source/Form/Field'; |
| 8 | +import { Button } from 'boot-cell/source/Form/Button'; |
| 9 | +import { CarouselView } from 'boot-cell/source/Content/Carousel'; |
| 10 | + |
| 11 | +import { Feature } from './Feature'; |
| 12 | +import style from './index.less'; |
| 13 | + |
| 14 | +import { github } from '../../../model'; |
| 15 | +import { headers, banners, features } from './data'; |
| 16 | + |
| 17 | +interface CarouselPageState { |
| 18 | + projects: ReposListForOrgResponseData; |
| 19 | +} |
| 20 | + |
| 21 | +@component({ |
| 22 | + tagName: 'carousel-page', |
| 23 | + renderTarget: 'children' |
| 24 | +}) |
| 25 | +export class CarouselPage extends mixin<{}, CarouselPageState>() { |
| 26 | + state = { |
| 27 | + projects: [] as ReposListForOrgResponseData |
| 28 | + }; |
| 29 | + |
| 30 | + async connectedCallback() { |
| 31 | + super.connectedCallback(); |
| 32 | + |
| 33 | + const { body } = await github.get<ReposListForOrgResponseData>( |
| 34 | + 'orgs/EasyWebApp/repos' |
| 35 | + ); |
| 36 | + |
| 37 | + await this.setState({ |
| 38 | + projects: body |
| 39 | + .sort(({ updated_at: A }, { updated_at: B }) => |
| 40 | + B.localeCompare(A) |
| 41 | + ) |
| 42 | + .slice(0, 3) |
| 43 | + }); |
| 44 | + } |
| 45 | + |
| 46 | + render(_, { projects }: CarouselPageState) { |
| 47 | + return ( |
| 48 | + <Fragment> |
| 49 | + <NavBar brand="Carousel" menu={headers}> |
| 50 | + <Form inline className="my-2 my-lg-0"> |
| 51 | + <Field |
| 52 | + type="search" |
| 53 | + className="mr-sm-2" |
| 54 | + placeholder="Search" |
| 55 | + aria-label="Search" |
| 56 | + /> |
| 57 | + <Button |
| 58 | + type="submit" |
| 59 | + kind="success" |
| 60 | + outline |
| 61 | + className="my-2 my-sm-0" |
| 62 | + > |
| 63 | + Search |
| 64 | + </Button> |
| 65 | + </Form> |
| 66 | + </NavBar> |
| 67 | + |
| 68 | + <CarouselView controls indicators interval={3} list={banners} /> |
| 69 | + |
| 70 | + <div className={classNames('container', style.marketing)}> |
| 71 | + <div className="row text-center"> |
| 72 | + {projects.map(({ name, description, html_url }) => ( |
| 73 | + <div className="col-lg-4 mb-4"> |
| 74 | + <img |
| 75 | + className="rounded-circle" |
| 76 | + style={{ width: '8.75rem' }} |
| 77 | + src="https://web-cell.dev/WebCell-0.f1ffd28b.png" |
| 78 | + /> |
| 79 | + <h2 style={{ fontWeight: 400 }}>{name}</h2> |
| 80 | + <p>{description}</p> |
| 81 | + <p> |
| 82 | + <Button kind="secondary" href={html_url}> |
| 83 | + View details » |
| 84 | + </Button> |
| 85 | + </p> |
| 86 | + </div> |
| 87 | + ))} |
| 88 | + </div> |
| 89 | + <hr className={style['featurette-divider']} /> |
| 90 | + |
| 91 | + {features.map((item, index) => ( |
| 92 | + <Fragment> |
| 93 | + <Feature reverse={!!(index % 2)} {...item} /> |
| 94 | + <hr className={style['featurette-divider']} /> |
| 95 | + </Fragment> |
| 96 | + ))} |
| 97 | + </div> |
| 98 | + <footer class="container"> |
| 99 | + <p class="float-right"> |
| 100 | + <a href="#top">Back to top</a> |
| 101 | + </p> |
| 102 | + <p> |
| 103 | + © 2017-{new Date().getFullYear()} Company, Inc. ·{' '} |
| 104 | + <a href="#">Privacy</a> · <a href="#">Terms</a> |
| 105 | + </p> |
| 106 | + </footer> |
| 107 | + </Fragment> |
| 108 | + ); |
| 109 | + } |
| 110 | +} |
0 commit comments