mirror of
https://github.com/outline/outline.git
synced 2026-11-25 15:15:15 +03:00
chore: UI tweaks (#10606)
* chore: Add transition on button mouseout * Change default API key expiration to 1 month * fix: Image upload triggered twice on New Application form * Improve clickarea of sidebar disclosures ref #10482 * Interaction fade
This commit is contained in:
1 parent
2c74a801a4
commit
e85e31a481
6 files changed
+104
-70
No files matched your search
@@ -34,6 +34,7 @@ const RealButton = styled(ActionButton)<RealProps>`
|
||||
cursor: var(--pointer);
|
||||
user-select: none;
|
||||
appearance: none !important;
|
||||
transition: background 200ms ease-out;
|
||||
${undraggableOnDesktop()}
|
||||
|
||||
&::-moz-focus-inner {
|
||||
@@ -44,6 +45,7 @@ const RealButton = styled(ActionButton)<RealProps>`
|
||||
&:hover:not(:disabled),
|
||||
&[aria-expanded="true"] {
|
||||
background: ${(props) => darken(0.05, props.theme.accent)};
|
||||
transition: background 0s;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
@@ -78,6 +80,7 @@ const RealButton = styled(ActionButton)<RealProps>`
|
||||
box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 2px, ${
|
||||
props.theme.buttonNeutralBorder
|
||||
} 0 0 0 1px inset;
|
||||
transition: background 0s;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
@@ -103,6 +106,7 @@ const RealButton = styled(ActionButton)<RealProps>`
|
||||
&:hover:not(:disabled),
|
||||
&[aria-expanded="true"] {
|
||||
background: ${darken(0.05, props.theme.danger)};
|
||||
transition: background 0s;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
|
||||
@@ -42,27 +42,47 @@ function EditableTitle(
|
||||
setValue(title);
|
||||
}, [title]);
|
||||
|
||||
const handleChange = React.useCallback((event) => {
|
||||
setValue(event.target.value);
|
||||
}, []);
|
||||
const handleChange = React.useCallback(
|
||||
(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setValue(event.target.value);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleDoubleClick = React.useCallback((event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setIsEditing(true);
|
||||
}, []);
|
||||
const handleDoubleClick = React.useCallback(
|
||||
(event: React.MouseEvent<HTMLSpanElement>) => {
|
||||
if (event.altKey) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setIsEditing(true);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const stopPropagation = React.useCallback((event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}, []);
|
||||
const stopPropagation = React.useCallback(
|
||||
(event: React.MouseEvent<HTMLSpanElement>) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleFocus = React.useCallback((event) => {
|
||||
event.target.select();
|
||||
}, []);
|
||||
const handleFocus = React.useCallback(
|
||||
(event: React.FocusEvent<HTMLInputElement>) => {
|
||||
event.target.select();
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleSave = React.useCallback(
|
||||
async (ev) => {
|
||||
async (
|
||||
ev:
|
||||
| React.FocusEvent<HTMLInputElement>
|
||||
| React.KeyboardEvent<HTMLInputElement>
|
||||
| React.FormEvent<HTMLFormElement>
|
||||
) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
@@ -98,7 +118,7 @@ function EditableTitle(
|
||||
);
|
||||
|
||||
const handleKeyDown = React.useCallback(
|
||||
async (ev) => {
|
||||
async (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (ev.nativeEvent.isComposing) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import Flex from "~/components/Flex";
|
||||
import Input, { LabelText } from "~/components/Input";
|
||||
import isCloudHosted from "~/utils/isCloudHosted";
|
||||
import Switch from "../Switch";
|
||||
import EventBoundary from "@shared/components/EventBoundary";
|
||||
|
||||
export interface FormData {
|
||||
name: string;
|
||||
@@ -62,17 +63,19 @@ export const OAuthClientForm = observer(function OAuthClientForm_({
|
||||
control={control}
|
||||
name="avatarUrl"
|
||||
render={({ field }) => (
|
||||
<ImageInput
|
||||
alt={t("OAuth client icon")}
|
||||
onSuccess={(url) => field.onChange(url)}
|
||||
onError={(err) => setError("avatarUrl", { message: err })}
|
||||
model={{
|
||||
id: oauthClient?.id,
|
||||
avatarUrl: field.value,
|
||||
initial: getValues().name[0],
|
||||
}}
|
||||
borderRadius={0}
|
||||
/>
|
||||
<EventBoundary>
|
||||
<ImageInput
|
||||
alt={t("OAuth client icon")}
|
||||
onSuccess={(url) => field.onChange(url)}
|
||||
onError={(err) => setError("avatarUrl", { message: err })}
|
||||
model={{
|
||||
id: oauthClient?.id,
|
||||
avatarUrl: field.value,
|
||||
initial: getValues().name[0],
|
||||
}}
|
||||
borderRadius={0}
|
||||
/>
|
||||
</EventBoundary>
|
||||
)}
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
import { CollapsedIcon } from "outline-icons";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled, { css } from "styled-components";
|
||||
import { s } from "@shared/styles";
|
||||
import styled from "styled-components";
|
||||
import { extraArea, s } from "@shared/styles";
|
||||
import NudeButton from "~/components/NudeButton";
|
||||
|
||||
type Props = React.ComponentProps<typeof Button> & {
|
||||
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
||||
expanded: boolean;
|
||||
root?: boolean;
|
||||
};
|
||||
|
||||
function Disclosure({ onClick, root, expanded, ...rest }: Props) {
|
||||
function Disclosure({ onClick, expanded, ...rest }: Props) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Button
|
||||
size={20}
|
||||
onClick={onClick}
|
||||
$root={root}
|
||||
aria-label={expanded ? t("Collapse") : t("Expand")}
|
||||
{...rest}
|
||||
>
|
||||
@@ -27,28 +25,18 @@ function Disclosure({ onClick, root, expanded, ...rest }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
const Button = styled(NudeButton)<{ $root?: boolean }>`
|
||||
const Button = styled(NudeButton)`
|
||||
position: absolute;
|
||||
left: -24px;
|
||||
flex-shrink: 0;
|
||||
color: ${s("textSecondary")};
|
||||
margin: 2px;
|
||||
${extraArea(4)}
|
||||
|
||||
&:hover {
|
||||
color: ${s("text")};
|
||||
background: ${s("sidebarControlHoverBackground")};
|
||||
}
|
||||
|
||||
${(props) =>
|
||||
props.$root &&
|
||||
css`
|
||||
opacity: 0;
|
||||
left: -18px;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
background: none;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
const StyledCollapsedIcon = styled(CollapsedIcon)<{
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as React from "react";
|
||||
import styled, { useTheme, css } from "styled-components";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import EventBoundary from "@shared/components/EventBoundary";
|
||||
import { s } from "@shared/styles";
|
||||
import { hover, s } from "@shared/styles";
|
||||
import { isMobile } from "@shared/utils/browser";
|
||||
import NudeButton from "~/components/NudeButton";
|
||||
import { UnreadBadge } from "~/components/UnreadBadge";
|
||||
@@ -108,6 +108,20 @@ function SidebarLink(
|
||||
);
|
||||
|
||||
const [openContextMenu, setOpen, setClosed] = useBoolean(false);
|
||||
const DisclosureComponent = depth === 0 ? HiddenDisclosure : Disclosure;
|
||||
|
||||
const handleClickCapture = React.useCallback(
|
||||
(event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||
if (event.altKey && onDisclosureClick && expanded !== undefined) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onDisclosureClick(
|
||||
event as unknown as React.MouseEvent<HTMLButtonElement>
|
||||
);
|
||||
}
|
||||
},
|
||||
[onDisclosureClick, expanded]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -123,6 +137,7 @@ function SidebarLink(
|
||||
$disabled={disabled}
|
||||
activeStyle={isActiveDrop ? activeDropStyle : activeStyle}
|
||||
style={openContextMenu ? hoverStyle : active ? activeStyle : style}
|
||||
onClickCapture={handleClickCapture}
|
||||
onClick={onClick}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
@@ -137,11 +152,10 @@ function SidebarLink(
|
||||
>
|
||||
<Content>
|
||||
{expanded !== undefined && (
|
||||
<Disclosure
|
||||
<DisclosureComponent
|
||||
expanded={expanded}
|
||||
onMouseDown={onDisclosureClick}
|
||||
onClick={preventDefault}
|
||||
root={depth === 0}
|
||||
tabIndex={-1}
|
||||
/>
|
||||
)}
|
||||
@@ -156,18 +170,6 @@ function SidebarLink(
|
||||
);
|
||||
}
|
||||
|
||||
const Content = styled.span`
|
||||
display: flex;
|
||||
align-items: start;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
${Disclosure} {
|
||||
margin-top: 2px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
`;
|
||||
|
||||
// accounts for whitespace around icon
|
||||
export const IconWrapper = styled.span`
|
||||
margin-left: -4px;
|
||||
@@ -175,6 +177,14 @@ export const IconWrapper = styled.span`
|
||||
height: 24px;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
transition: opacity 200ms ease-in-out;
|
||||
`;
|
||||
|
||||
const Content = styled.span`
|
||||
display: flex;
|
||||
align-items: start;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const Actions = styled(EventBoundary)<{ showActions?: boolean }>`
|
||||
@@ -203,6 +213,14 @@ const Actions = styled(EventBoundary)<{ showActions?: boolean }>`
|
||||
}
|
||||
`;
|
||||
|
||||
const HiddenDisclosure = styled(Disclosure)`
|
||||
position: inherit;
|
||||
left: initial;
|
||||
display: none;
|
||||
margin-left: -2px;
|
||||
margin-right: 6px;
|
||||
`;
|
||||
|
||||
const Link = styled(NavLink)<{
|
||||
$isActiveDrop?: boolean;
|
||||
$isDraft?: boolean;
|
||||
@@ -253,8 +271,15 @@ const Link = styled(NavLink)<{
|
||||
transition: fill 50ms;
|
||||
}
|
||||
|
||||
&:hover svg {
|
||||
display: inline;
|
||||
&: ${hover} {
|
||||
${HiddenDisclosure} {
|
||||
display: block;
|
||||
}
|
||||
${HiddenDisclosure} + ${IconWrapper} {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
& + ${Actions} {
|
||||
@@ -293,12 +318,6 @@ const Link = styled(NavLink)<{
|
||||
props.$isActiveDrop ? props.theme.white : props.theme.text};
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
${Disclosure} {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const Label = styled.div`
|
||||
|
||||
@@ -24,7 +24,7 @@ function ApiKeyNew({ onSubmit }: Props) {
|
||||
const [name, setName] = React.useState("");
|
||||
const [scope, setScope] = React.useState("");
|
||||
const [expiryType, setExpiryType] = React.useState<ExpiryType>(
|
||||
ExpiryType.Week
|
||||
ExpiryType.Month
|
||||
);
|
||||
const currentDate = React.useRef<Date>(new Date());
|
||||
const [expiresAt, setExpiresAt] = React.useState<Date | undefined>(() =>
|
||||
|
||||
Reference in new issue
Block a user