一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
35 行
845 B
TypeScript
35 行
845 B
TypeScript
import * as React from 'react';
|
|
import { _ } from '@joplin/lib/locale';
|
|
|
|
interface ExpandIconProps {
|
|
isExpanded: boolean;
|
|
isVisible: boolean;
|
|
}
|
|
|
|
const ExpandIcon: React.FC<ExpandIconProps> = props => {
|
|
const classNames = ['sidebar-expand-icon'];
|
|
if (props.isVisible) classNames.push('-visible');
|
|
classNames.push(props.isExpanded ? 'fas fa-caret-down' : 'fas fa-caret-right');
|
|
|
|
// Referencing the name of the item we expand/collapse is both good for accessibility
|
|
// and makes writing tests easier.
|
|
const getLabel = () => {
|
|
if (!props.isVisible) {
|
|
return undefined;
|
|
}
|
|
if (props.isExpanded) {
|
|
return _('Expanded');
|
|
}
|
|
return _('Collapsed');
|
|
};
|
|
const label = getLabel();
|
|
return <i
|
|
className={classNames.join(' ')}
|
|
aria-hidden={!props.isVisible}
|
|
aria-label={label}
|
|
role='img'
|
|
></i>;
|
|
};
|
|
|
|
export default ExpandIcon;
|