Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: use emotion for styling (pt. 3)#10026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 16 commits intomainfromemotional-damage-3
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 33 additions & 41 deletionssite/src/components/CodeExample/CodeExample.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import {makeStyles} from "@mui/styles";
import {FC } from "react";
import {type FC} from "react";
import {useTheme } from "@emotion/react";
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
import { combineClasses } from "utils/combineClasses";
import { CopyButton } from "../CopyButton/CopyButton";
import { Theme } from "@mui/material/styles";

export interface CodeExampleProps {
code: string;
Expand All@@ -14,46 +12,40 @@ export interface CodeExampleProps {
/**
* Component to show single-line code examples, with a copy button
*/
export const CodeExample: FC<CodeExampleProps> = ({
code,
password,
className,
}) => {
const styles = useStyles({ password });
export const CodeExample: FC<CodeExampleProps> = (props) => {
const { code, password, className } = props;
const theme = useTheme();

return (
<div className={combineClasses([styles.root, className])}>
<code className={styles.code}>{code}</code>
<div
css={{
display: "flex",
flexDirection: "row",
alignItems: "center",
background: "rgb(0 0 0 / 30%)",
color: theme.palette.primary.contrastText,
fontFamily: MONOSPACE_FONT_FAMILY,
fontSize: 14,
borderRadius: theme.shape.borderRadius,
padding: theme.spacing(1),
lineHeight: "150%",
border: `1px solid ${theme.palette.divider}`,
}}
className={className}
>
<code
css={{
padding: theme.spacing(0, 1),
width: "100%",
display: "flex",
alignItems: "center",
wordBreak: "break-all",
"-webkit-text-security": password ? "disc" : undefined,
}}
>
{code}
</code>
<CopyButton text={code} />
</div>
);
};

interface styleProps {
inline?: boolean;
password?: boolean;
}

const useStyles = makeStyles<Theme, styleProps>((theme) => ({
root: (props) => ({
display: props.inline ? "inline-flex" : "flex",
flexDirection: "row",
alignItems: "center",
background: "rgb(0 0 0 / 30%)",
color: theme.palette.primary.contrastText,
fontFamily: MONOSPACE_FONT_FAMILY,
fontSize: 14,
borderRadius: theme.shape.borderRadius,
padding: theme.spacing(1),
lineHeight: "150%",
border: `1px solid ${theme.palette.divider}`,
}),
code: {
padding: theme.spacing(0, 1),
width: "100%",
display: "flex",
alignItems: "center",
wordBreak: "break-all",
"-webkit-text-security": (props) => (props.password ? "disc" : undefined),
},
}));
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,10 +5,7 @@ import { colors } from "theme/colors";
import * as TypesGen from "api/typesGenerated";
import { navHeight } from "theme/constants";
import { BorderedMenu } from "./BorderedMenu";
import {
CloseDropdown,
OpenDropdown,
} from "components/DropdownArrows/DropdownArrows";
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
import { UserAvatar } from "components/UserAvatar/UserAvatar";
import { UserDropdownContent } from "./UserDropdownContent";
import { BUTTON_SM_HEIGHT } from "theme/theme";
Expand DownExpand Up@@ -69,11 +66,7 @@ export const UserDropdown: FC<PropsWithChildren<UserDropdownProps>> = ({
avatarURL={user.avatar_url}
/>
</Badge>
{anchorEl ? (
<CloseDropdown color={colors.gray[6]} />
) : (
<OpenDropdown color={colors.gray[6]} />
)}
<DropdownArrow color={colors.gray[6]} close={Boolean(anchorEl)} />
</div>
</MenuItem>

Expand Down
28 changes: 28 additions & 0 deletionssite/src/components/DropdownArrow/DropdownArrow.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown";
import KeyboardArrowUp from "@mui/icons-material/KeyboardArrowUp";
import { type FC } from "react";
import { type Theme } from "@emotion/react";

interface ArrowProps {
margin?: boolean;
color?: string;
close?: boolean;
}

export const DropdownArrow: FC<ArrowProps> = (props) => {
const { margin = true, color, close } = props;

const Arrow = close ? KeyboardArrowUp : KeyboardArrowDown;

return (
<Arrow
aria-label={close ? "close-dropdown" : "open-dropdown"}
css={(theme: Theme) => ({
color: color ?? theme.palette.primary.contrastText,
marginLeft: margin ? theme.spacing(1) : 0,
width: 16,
height: 16,
})}
/>
);
};
42 changes: 0 additions & 42 deletionssite/src/components/DropdownArrows/DropdownArrows.tsx
View file
Open in desktop

This file was deleted.

13 changes: 5 additions & 8 deletionssite/src/components/Expander/Expander.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
import Collapse from "@mui/material/Collapse";
import Link from "@mui/material/Link";
import makeStyles from "@mui/styles/makeStyles";
import {
CloseDropdown,
OpenDropdown,
} from "components/DropdownArrows/DropdownArrows";
import { PropsWithChildren, FC } from "react";
import Collapse from "@mui/material/Collapse";
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
import { type FC, type PropsWithChildren } from "react";
import { combineClasses } from "utils/combineClasses";

export interface ExpanderProps {
Expand All@@ -28,7 +25,7 @@ export const Expander: FC<PropsWithChildren<ExpanderProps>> = ({
<Link onClick={toggleExpanded} className={styles.expandLink}>
<span className={styles.text}>
Click here to learn more
<OpenDropdown margin={false} />
<DropdownArrow margin={false} />
</span>
</Link>
)}
Expand All@@ -42,7 +39,7 @@ export const Expander: FC<PropsWithChildren<ExpanderProps>> = ({
>
<span className={styles.text}>
Click here to hide
<CloseDropdown margin={false} />
<DropdownArrow margin={false} close />
</span>
</Link>
)}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp