on master help sign in
Merge pull request #265 from urbit/mino-greeting

Display view-once greeting on Point page

commit3c61bb3e7b3262cd1d8915c9a5b467f4595fd9df authorFang <Fang-@users.noreply.github.com> dateTue 3 Sep 2019, 20:24 (7 years ago) parent3523743cea0f60
3 files changed+84
src/components/Greeting.js+75 src/lib/useWasGreeted.js+7 src/views/Point.js+2
src/components/Greeting.jsnew file+75
@@ -0,0 +1,75 @@
1+import React, { useCallback } from 'react';
2+import cn from 'classnames';
3+import * as ob from 'urbit-ob';
4+import { Grid, Text, LinkButton } from 'indigo-react';
5+
6+import { useLocalRouter } from 'lib/LocalRouter';
7+
8+import useWasGreeted from 'lib/useWasGreeted';
9+import useCurrentPermissions from 'lib/useCurrentPermissions';
10+
11+const TEXT_STYLE = 'f5';
12+
13+export default function ActivateDisclaimer({ point }) {
14+ const { push, names } = useLocalRouter();
15+
16+ const [wasGreeted, setWasGreeted] = useWasGreeted();
17+ const { isActiveOwner } = useCurrentPermissions();
18+
19+ const pointName = ob.patp(point);
20+
21+ const dismiss = useCallback(async () => {
22+ setWasGreeted(true);
23+ }, [setWasGreeted]);
24+
25+ const goInvite = useCallback(() => push(names.INVITE), [push, names]);
26+
27+ return (
28+ !wasGreeted && (
29+ <Grid gap={4} className="mb10">
30+ <Grid.Item full>
31+ <Text className={cn(TEXT_STYLE, 'block mb4')}>
32+ Welcome <code>{pointName}</code>,
33+ </Text>
34+
35+ <Text className={cn(TEXT_STYLE, 'block mb2')}>
36+ As of this very moment, you own an Urbit identity – a digital
37+ identity that you can keep for the rest of your life. Use the Master
38+ Ticket included in your Passport to access your Urbit identity at
39+ any time. Right now you can:
40+ </Text>
41+ </Grid.Item>
42+
43+ {isActiveOwner && (
44+ <Grid.Item
45+ full
46+ as={LinkButton}
47+ onClick={goInvite}
48+ className={'yellow4'}>
49+ <Text className={cn(TEXT_STYLE, 'block mb2')}>
50+ Invite your friends
51+ </Text>
52+ </Grid.Item>
53+ )}
54+
55+ <Grid.Item
56+ full
57+ as={LinkButton}
58+ href="https://urbit.org/docs/getting-started/">
59+ <Text className={cn(TEXT_STYLE, 'block mb2')}>
60+ Boot your computer
61+ </Text>
62+ </Grid.Item>
63+
64+ <Grid.Item full>
65+ <Text className={cn(TEXT_STYLE, 'block mb4')}>
66+ Welcome to Urbit. See you online.
67+ </Text>
68+ </Grid.Item>
69+ <Grid.Item full as={LinkButton} onClick={dismiss}>
70+ Close
71+ </Grid.Item>
72+ </Grid>
73+ )
74+ );
75+}
src/lib/useWasGreeted.jsnew file+7
@@ -0,0 +1,7 @@
1+import useLocalStorageState from './useLocalStorageState';
2+
3+const WAS_GREETED_KEY = 'bridge:was-greeted';
4+
5+export default function useWasGreeted() {
6+ return useLocalStorageState(WAS_GREETED_KEY, false);
7+}
src/views/Point.js+2
@@ -7,6 +7,7 @@ import { azimuth } from 'azimuth-js';
77import { usePointCursor } from 'store/pointCursor';
88
99import View from 'components/View';
10+import Greeting from 'components/Greeting';
1011import Passport from 'components/Passport';
1112import { ForwardButton, BootArvoButton } from 'components/Buttons';
1213import { matchBlinky } from 'components/Blinky';
@@ -87,6 +88,7 @@ export default function Point() {
8788
8889 return (
8990 <View pop={pop} inset>
91+ <Greeting point={point} />
9092 <Passport point={Just(point)} />
9193 <Grid className="pt2">
9294 {inviteButton}