mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Update components
This commit is contained in:
parent
08d182acda
commit
7a5df2fc5e
8 changed files with 39 additions and 22 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type {NotificationProps, NotificationState} from '../hyper';
|
import type {NotificationProps, NotificationState} from '../hyper';
|
||||||
|
|
||||||
export default class Notification extends React.PureComponent<NotificationProps, NotificationState> {
|
export default class Notification extends React.PureComponent<
|
||||||
|
React.PropsWithChildren<NotificationProps>,
|
||||||
|
NotificationState
|
||||||
|
> {
|
||||||
dismissTimer!: NodeJS.Timeout;
|
dismissTimer!: NodeJS.Timeout;
|
||||||
constructor(props: NotificationProps) {
|
constructor(props: NotificationProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, {forwardRef} from 'react';
|
||||||
|
|
||||||
import {decorate} from '../utils/plugins';
|
import {decorate} from '../utils/plugins';
|
||||||
|
|
||||||
|
|
@ -7,9 +7,9 @@ import type {NotificationsProps} from '../hyper';
|
||||||
|
|
||||||
const Notification = decorate(Notification_, 'Notification');
|
const Notification = decorate(Notification_, 'Notification');
|
||||||
|
|
||||||
const Notifications: React.FC<NotificationsProps> = (props) => {
|
const Notifications = forwardRef<HTMLDivElement, NotificationsProps>((props, ref) => {
|
||||||
return (
|
return (
|
||||||
<div className="notifications_view">
|
<div className="notifications_view" ref={ref}>
|
||||||
{props.customChildrenBefore}
|
{props.customChildrenBefore}
|
||||||
{props.fontShowing && (
|
{props.fontShowing && (
|
||||||
<Notification
|
<Notification
|
||||||
|
|
@ -125,6 +125,8 @@ const Notifications: React.FC<NotificationsProps> = (props) => {
|
||||||
`}</style>
|
`}</style>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
Notifications.displayName = 'Notifications';
|
||||||
|
|
||||||
export default Notifications;
|
export default Notifications;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, {useCallback, useRef, useEffect} from 'react';
|
import React, {useCallback, useRef, useEffect, forwardRef} from 'react';
|
||||||
import type {SearchBoxProps} from '../hyper';
|
import type {SearchBoxProps} from '../hyper';
|
||||||
import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp';
|
import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp';
|
||||||
import {VscArrowDown} from '@react-icons/all-files/vsc/VscArrowDown';
|
import {VscArrowDown} from '@react-icons/all-files/vsc/VscArrowDown';
|
||||||
|
|
@ -82,7 +82,7 @@ const SearchButton = ({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const SearchBox = (props: SearchBoxProps) => {
|
const SearchBox = forwardRef<HTMLDivElement, SearchBoxProps>((props, ref) => {
|
||||||
const {
|
const {
|
||||||
caseSensitive,
|
caseSensitive,
|
||||||
wholeWord,
|
wholeWord,
|
||||||
|
|
@ -127,7 +127,7 @@ const SearchBox = (props: SearchBoxProps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-row search-container">
|
<div className="flex-row search-container" ref={ref}>
|
||||||
<div className="flex-row search-box">
|
<div className="flex-row search-box">
|
||||||
<input className="search-input" type="text" onKeyDown={handleChange} ref={inputRef} placeholder="Search" />
|
<input className="search-input" type="text" onKeyDown={handleChange} ref={inputRef} placeholder="Search" />
|
||||||
|
|
||||||
|
|
@ -228,6 +228,8 @@ const SearchBox = (props: SearchBoxProps) => {
|
||||||
</style>
|
</style>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
SearchBox.displayName = 'SearchBox';
|
||||||
|
|
||||||
export default SearchBox;
|
export default SearchBox;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@ import React from 'react';
|
||||||
import sum from 'lodash/sum';
|
import sum from 'lodash/sum';
|
||||||
import type {SplitPaneProps} from '../hyper';
|
import type {SplitPaneProps} from '../hyper';
|
||||||
|
|
||||||
export default class SplitPane extends React.PureComponent<SplitPaneProps, {dragging: boolean}> {
|
export default class SplitPane extends React.PureComponent<
|
||||||
|
React.PropsWithChildren<SplitPaneProps>,
|
||||||
|
{dragging: boolean}
|
||||||
|
> {
|
||||||
dragPanePosition!: number;
|
dragPanePosition!: number;
|
||||||
dragTarget!: Element;
|
dragTarget!: Element;
|
||||||
panes!: Element[];
|
panes!: Element[];
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import React from 'react';
|
import React, {forwardRef} from 'react';
|
||||||
import type {StyleSheetProps} from '../hyper';
|
import type {StyleSheetProps} from '../hyper';
|
||||||
|
|
||||||
const StyleSheet: React.FC<StyleSheetProps> = (props) => {
|
const StyleSheet: React.FC<StyleSheetProps> = forwardRef<HTMLStyleElement, StyleSheetProps>((props, ref) => {
|
||||||
const {borderColor} = props;
|
const {borderColor} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<style jsx global>{`
|
<style jsx global ref={ref}>{`
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
}
|
}
|
||||||
|
|
@ -19,6 +19,8 @@ const StyleSheet: React.FC<StyleSheetProps> = (props) => {
|
||||||
}
|
}
|
||||||
`}</style>
|
`}</style>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
StyleSheet.displayName = 'StyleSheet';
|
||||||
|
|
||||||
export default StyleSheet;
|
export default StyleSheet;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React, {forwardRef} from 'react';
|
||||||
import type {TabProps} from '../hyper';
|
import type {TabProps} from '../hyper';
|
||||||
|
|
||||||
const Tab = (props: TabProps) => {
|
const Tab = forwardRef<HTMLLIElement, TabProps>((props, ref) => {
|
||||||
const handleClick = (event: React.MouseEvent) => {
|
const handleClick = (event: React.MouseEvent) => {
|
||||||
const isLeftClick = event.nativeEvent.which === 1;
|
const isLeftClick = event.nativeEvent.which === 1;
|
||||||
|
|
||||||
|
|
@ -28,6 +28,7 @@ const Tab = (props: TabProps) => {
|
||||||
className={`tab_tab ${isFirst ? 'tab_first' : ''} ${isActive ? 'tab_active' : ''} ${
|
className={`tab_tab ${isFirst ? 'tab_first' : ''} ${isActive ? 'tab_active' : ''} ${
|
||||||
isFirst && isActive ? 'tab_firstActive' : ''
|
isFirst && isActive ? 'tab_firstActive' : ''
|
||||||
} ${hasActivity ? 'tab_hasActivity' : ''}`}
|
} ${hasActivity ? 'tab_hasActivity' : ''}`}
|
||||||
|
ref={ref}
|
||||||
>
|
>
|
||||||
{props.customChildrenBefore}
|
{props.customChildrenBefore}
|
||||||
<span
|
<span
|
||||||
|
|
@ -159,6 +160,8 @@ const Tab = (props: TabProps) => {
|
||||||
`}</style>
|
`}</style>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
Tab.displayName = 'Tab';
|
||||||
|
|
||||||
export default Tab;
|
export default Tab;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, {forwardRef} from 'react';
|
||||||
|
|
||||||
import {decorate, getTabProps} from '../utils/plugins';
|
import {decorate, getTabProps} from '../utils/plugins';
|
||||||
|
|
||||||
|
|
@ -9,13 +9,13 @@ import DropdownButton from './new-tab';
|
||||||
const Tab = decorate(Tab_, 'Tab');
|
const Tab = decorate(Tab_, 'Tab');
|
||||||
const isMac = /Mac/.test(navigator.userAgent);
|
const isMac = /Mac/.test(navigator.userAgent);
|
||||||
|
|
||||||
const Tabs = (props: TabsProps) => {
|
const Tabs = forwardRef<HTMLElement, TabsProps>((props, ref) => {
|
||||||
const {tabs = [], borderColor, onChange, onClose, fullScreen} = props;
|
const {tabs = [], borderColor, onChange, onClose, fullScreen} = props;
|
||||||
|
|
||||||
const hide = !isMac && tabs.length === 1;
|
const hide = !isMac && tabs.length === 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className={`tabs_nav ${hide ? 'tabs_hiddenNav' : ''}`}>
|
<nav className={`tabs_nav ${hide ? 'tabs_hiddenNav' : ''}`} ref={ref}>
|
||||||
{props.customChildrenBefore}
|
{props.customChildrenBefore}
|
||||||
{tabs.length === 1 && isMac ? <div className="tabs_title">{tabs[0].title}</div> : null}
|
{tabs.length === 1 && isMac ? <div className="tabs_title">{tabs[0].title}</div> : null}
|
||||||
{tabs.length > 1 ? (
|
{tabs.length > 1 ? (
|
||||||
|
|
@ -106,6 +106,8 @@ const Tabs = (props: TabsProps) => {
|
||||||
`}</style>
|
`}</style>
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
Tabs.displayName = 'Tabs';
|
||||||
|
|
||||||
export default Tabs;
|
export default Tabs;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ const StyleSheet = decorate(StyleSheet_, 'StyleSheet');
|
||||||
|
|
||||||
const isMac = /Mac/.test(navigator.userAgent);
|
const isMac = /Mac/.test(navigator.userAgent);
|
||||||
|
|
||||||
export default class Terms extends React.Component<TermsProps> {
|
export default class Terms extends React.Component<React.PropsWithChildren<TermsProps>> {
|
||||||
terms: Record<string, Term>;
|
terms: Record<string, Term>;
|
||||||
registerCommands: (cmds: Record<string, (e: any, dispatch: HyperDispatch) => void>) => void;
|
registerCommands: (cmds: Record<string, (e: any, dispatch: HyperDispatch) => void>) => void;
|
||||||
constructor(props: TermsProps, context: any) {
|
constructor(props: TermsProps, context: any) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue