mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
leap: display chording options
This commit is contained in:
parent
a0a04746e7
commit
7ce67a2b46
@ -11,19 +11,23 @@ const makeIndexes = () => new Map([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// result schematic
|
// result schematic
|
||||||
const result = function(title, link, app, host) {
|
const result = function(title, link, app, host, description = 'Open', shiftLink = null, shiftDescription = null) {
|
||||||
return {
|
return {
|
||||||
'title': title,
|
'title': title,
|
||||||
'link': link,
|
'link': link,
|
||||||
'app': app,
|
'app': app,
|
||||||
'host': host
|
'host': host,
|
||||||
|
'description': description,
|
||||||
|
'shiftLink': shiftLink,
|
||||||
|
'shiftDescription': shiftDescription
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const shipIndex = function(contacts) {
|
const shipIndex = function(contacts) {
|
||||||
const ships = [];
|
const ships = [];
|
||||||
Object.keys(contacts).map((e) => {
|
Object.keys(contacts).map((e) => {
|
||||||
return ships.push(result(e, `/~profile/${e}`, 'profile', contacts[e]?.status || ''));
|
return ships.push(result(e, `/~profile/${e}`, 'profile', contacts[e]?.status || '', 'Open Profile', `/~landscape/messages/dm/${e}`, 'Send Message'));
|
||||||
});
|
});
|
||||||
return ships;
|
return ships;
|
||||||
};
|
};
|
||||||
|
@ -329,7 +329,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
|
|||||||
);
|
);
|
||||||
const sel = selected?.length ? selected[1] : '';
|
const sel = selected?.length ? selected[1] : '';
|
||||||
return (
|
return (
|
||||||
<Box key={i} width='max(50vw, 300px)' maxWidth='600px'>
|
<Box key={i} width='max(50vw, 300px)' maxWidth='700px'>
|
||||||
{categoryTitle}
|
{categoryTitle}
|
||||||
{categoryResults.sort(sortResults).map((result, i2) => (
|
{categoryResults.sort(sortResults).map((result, i2) => (
|
||||||
<OmniboxResult
|
<OmniboxResult
|
||||||
@ -338,6 +338,9 @@ export function Omnibox(props: OmniboxProps): ReactElement {
|
|||||||
icon={result.app}
|
icon={result.app}
|
||||||
text={result.title}
|
text={result.title}
|
||||||
subtext={result.host}
|
subtext={result.host}
|
||||||
|
shiftLink={result.shiftLink}
|
||||||
|
shiftDescription={result.shiftDescription}
|
||||||
|
description={result.description}
|
||||||
link={result.link}
|
link={result.link}
|
||||||
cursor={leapCursor}
|
cursor={leapCursor}
|
||||||
navigate={() => navigate(result.app, result.link, false)}
|
navigate={() => navigate(result.app, result.link, false)}
|
||||||
@ -366,9 +369,9 @@ export function Omnibox(props: OmniboxProps): ReactElement {
|
|||||||
>
|
>
|
||||||
<Row justifyContent='center'>
|
<Row justifyContent='center'>
|
||||||
<Box
|
<Box
|
||||||
mt={['10vh', '20vh']}
|
mt={['10vh', '15vh']}
|
||||||
width='max(50vw, 300px)'
|
width='max(50vw, 300px)'
|
||||||
maxWidth='600px'
|
maxWidth='700px'
|
||||||
borderRadius={2}
|
borderRadius={2}
|
||||||
backgroundColor='white'
|
backgroundColor='white'
|
||||||
ref={(el) => {
|
ref={(el) => {
|
||||||
|
@ -11,6 +11,22 @@ import useHarkState from '~/logic/state/hark';
|
|||||||
import useLaunchState from '~/logic/state/launch';
|
import useLaunchState from '~/logic/state/launch';
|
||||||
import useInviteState from '~/logic/state/invite';
|
import useInviteState from '~/logic/state/invite';
|
||||||
|
|
||||||
|
function OmniboxResultChord(props: {
|
||||||
|
label: string;
|
||||||
|
modifier?: string;
|
||||||
|
|
||||||
|
}) {
|
||||||
|
const { label, modifier } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Text display={['none', 'inline']} color="white" ml="2">
|
||||||
|
{label}
|
||||||
|
{ modifier ? (<Text display="inline-block" ml="1" p="1" borderRadius="1" color="blue" backgroundColor="white">{modifier}</Text>) : null}
|
||||||
|
<Text display="inline-block" ml="1" color="blue" borderRadius="1" p="1" backgroundColor="white">↩</Text>
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
interface OmniboxResultProps {
|
interface OmniboxResultProps {
|
||||||
contacts: Contacts;
|
contacts: Contacts;
|
||||||
cursor: string;
|
cursor: string;
|
||||||
@ -24,6 +40,7 @@ interface OmniboxResultProps {
|
|||||||
setSelection: () => void;
|
setSelection: () => void;
|
||||||
subtext: string;
|
subtext: string;
|
||||||
text: string;
|
text: string;
|
||||||
|
shift?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OmniboxResultState {
|
interface OmniboxResultState {
|
||||||
@ -230,7 +247,10 @@ export class OmniboxResult extends Component<OmniboxResultProps, OmniboxResultSt
|
|||||||
notificationsCount,
|
notificationsCount,
|
||||||
runtimeLag,
|
runtimeLag,
|
||||||
contacts,
|
contacts,
|
||||||
setSelection
|
setSelection,
|
||||||
|
shiftDescription,
|
||||||
|
description = 'Go',
|
||||||
|
shiftLink
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const color = contacts?.[text]
|
const color = contacts?.[text]
|
||||||
@ -249,8 +269,7 @@ export class OmniboxResult extends Component<OmniboxResultProps, OmniboxResultSt
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Row
|
<Row
|
||||||
py={2}
|
p={1}
|
||||||
px={2}
|
|
||||||
cursor={cursor}
|
cursor={cursor}
|
||||||
onMouseMove={() => setSelection()}
|
onMouseMove={() => setSelection()}
|
||||||
onMouseLeave={() => this.setHover(false)}
|
onMouseLeave={() => this.setHover(false)}
|
||||||
@ -259,6 +278,8 @@ export class OmniboxResult extends Component<OmniboxResultProps, OmniboxResultSt
|
|||||||
}
|
}
|
||||||
onClick={navigate}
|
onClick={navigate}
|
||||||
width='100%'
|
width='100%'
|
||||||
|
height="32px"
|
||||||
|
alignItems="center"
|
||||||
justifyContent='space-between'
|
justifyContent='space-between'
|
||||||
// @ts-ignore indigo-react doesn't allow us to pass refs
|
// @ts-ignore indigo-react doesn't allow us to pass refs
|
||||||
ref={this.result}
|
ref={this.result}
|
||||||
@ -284,8 +305,9 @@ export class OmniboxResult extends Component<OmniboxResultProps, OmniboxResultSt
|
|||||||
{text.startsWith('~') ? cite(text) : text}
|
{text.startsWith('~') ? cite(text) : text}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Text
|
<Text
|
||||||
pr={2}
|
pr={1}
|
||||||
display='inline-block'
|
display='inline-block'
|
||||||
verticalAlign='middle'
|
verticalAlign='middle'
|
||||||
color={this.state.hovered || selected === link ? 'white' : 'black'}
|
color={this.state.hovered || selected === link ? 'white' : 'black'}
|
||||||
@ -294,10 +316,15 @@ export class OmniboxResult extends Component<OmniboxResultProps, OmniboxResultSt
|
|||||||
textOverflow='ellipsis'
|
textOverflow='ellipsis'
|
||||||
whiteSpace='pre'
|
whiteSpace='pre'
|
||||||
overflow='hidden'
|
overflow='hidden'
|
||||||
maxWidth='40%'
|
maxWidth='60%'
|
||||||
textAlign='right'
|
textAlign='right'
|
||||||
>
|
>
|
||||||
{subtext}
|
{(selected === link) ? (
|
||||||
|
<>
|
||||||
|
<OmniboxResultChord label={description} />
|
||||||
|
{(shiftLink && shiftDescription) ? (<OmniboxResultChord label={shiftDescription} modifier="Shift" />) : null}
|
||||||
|
</>
|
||||||
|
) : subtext}
|
||||||
</Text>
|
</Text>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user