seamammals plugin

Summary: _typescript_

Reviewed By: passy

Differential Revision: D16936889

fbshipit-source-id: 68ec6a14e1ee4517d76816b4156f0eebaca27ab4
This commit is contained in:
Daniel Büchele
2019-08-23 07:17:15 -07:00
committed by Facebook Github Bot
parent f824329151
commit 651c9db5c4
2 changed files with 20 additions and 21 deletions

View File

@@ -3,7 +3,6 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
* @format * @format
* @flow strict-local
*/ */
import { import {
@@ -22,9 +21,9 @@ import React from 'react';
type Id = number; type Id = number;
type Row = { type Row = {
id: Id, id: Id;
title: string, title: string;
url: string, url: string;
}; };
function renderSidebar(row: Row) { function renderSidebar(row: Row) {
@@ -36,33 +35,32 @@ function renderSidebar(row: Row) {
} }
type State = { type State = {
selectedID: ?string, selectedID: string | null;
}; };
type PersistedState = { type PersistedState = {
[key: string]: Row, [key: string]: Row;
}; };
export default class SeaMammals extends FlipperPlugin< export default class SeaMammals extends FlipperPlugin<
State, State,
void, any,
PersistedState, PersistedState
> { > {
static defaultPersistedState = {}; static defaultPersistedState = {};
static persistedStateReducer = ( static persistedStateReducer<PersistedState>(
persistedState: PersistedState, persistedState: PersistedState,
method: string, method: string,
payload: Row, payload: Row,
) => { ) {
if (method === 'newRow') { if (method === 'newRow') {
return { return Object.assign({}, persistedState, {
...persistedState,
[payload.id]: payload, [payload.id]: payload,
}; });
} }
return persistedState; return persistedState;
}; }
static Container = styled(FlexRow)({ static Container = styled(FlexRow)({
backgroundColor: colors.macOSTitleBarBackgroundBlur, backgroundColor: colors.macOSTitleBarBackgroundBlur,
@@ -100,12 +98,13 @@ export default class SeaMammals extends FlipperPlugin<
} }
} }
class Card extends React.Component<{ class Card extends React.Component<
...Row, {
onSelect: () => void, onSelect: () => void;
selected: boolean, selected: boolean;
}> { } & Row
static Container = styled(FlexColumn)(props => ({ > {
static Container = styled(FlexColumn)((props: {selected?: boolean}) => ({
margin: 10, margin: 10,
borderRadius: 5, borderRadius: 5,
border: '2px solid black', border: '2px solid black',

View File

@@ -1,7 +1,7 @@
{ {
"name": "sea-mammals", "name": "sea-mammals",
"version": "1.0.0", "version": "1.0.0",
"main": "index.js", "main": "index.tsx",
"license": "MIT", "license": "MIT",
"icon": "apps", "icon": "apps",
"title": "Sea Mammals", "title": "Sea Mammals",