Skip to content

Commit 6a21f74

Browse files
committed
Meta key icons
1 parent 61ce0cb commit 6a21f74

File tree

11 files changed

+568
-548
lines changed

11 files changed

+568
-548
lines changed

‎public/assets/fonts/tgico.svg

+171-169
Loading

‎public/assets/fonts/tgico.ttf

1.63 KB
Binary file not shown.

‎public/assets/fonts/tgico.woff

1.63 KB
Binary file not shown.

‎src/components/sidebarLeft/tabs/passcodeLock/inlineSelect.module.scss

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
padding: 2rem;
2727
}
2828

29+
overflow: hidden;
30+
2931
min-width: 114px;
3032
border-radius: 8px;
3133

‎src/components/sidebarLeft/tabs/passcodeLock/inlineSelect.tsx

+6-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const InlineSelect: Component<{
3535
});
3636
});
3737

38-
const onEnter = async(el: Element, done: () => void) => {
38+
const onEnter = (el: Element, done: () => void) => {
3939
const selectEl = el.firstElementChild as HTMLElement;
4040
const selectOptionEl = selectEl.querySelector(`.${styles.selected}`);
4141

@@ -79,16 +79,14 @@ const InlineSelect: Component<{
7979
}
8080
}
8181
);
82-
83-
done();
8482
};
8583

86-
const onExit = (el: Element, done: () => void) => {
84+
const onExit = async(el: Element, done: () => void) => {
8785
const selectEl = el.firstElementChild as HTMLElement;
8886

89-
selectEl.animate({opacity: [1, 0]}, {duration: 120}).finished.then(() => {
90-
done();
91-
});
87+
await selectEl.animate({opacity: [1, 0]}, {duration: 120}).finished;
88+
89+
done();
9290
};
9391

9492
const onMouseMove = (e: MouseEvent) => {
@@ -139,9 +137,7 @@ const InlineSelect: Component<{
139137
classList={{
140138
[styles.selected]: isSelected(option.value)
141139
}}
142-
onClick={() => {
143-
props.onChange(option.value);
144-
}}
140+
onClick={[props.onChange, option.value]}
145141
>
146142
<span>{option.label}</span>
147143
</div>

‎src/components/sidebarLeft/tabs/passcodeLock/mainTab.tsx

+12-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import InlineSelect from './inlineSelect';
1515
import ShortcutBuilder, {ShortcutKey} from './shortcutBuilder';
1616

1717
import commonStyles from './common.module.scss';
18-
import styles from './main.module.scss';
18+
import styles from './mainTab.module.scss';
1919

2020
const MainTab = () => {
2121
return (
@@ -74,7 +74,7 @@ const PasscodeSetContent = () => {
7474

7575
const [isOpen, setIsOpen] = createSignal(false);
7676

77-
const [keys, setKeys] = createSignal<ShortcutKey[]>([]);
77+
const [keys, setKeys] = createSignal<ShortcutKey[]>(['Alt']);
7878

7979
const caption = (
8080
<>
@@ -113,15 +113,16 @@ const PasscodeSetContent = () => {
113113
ref={setAutoCloseRowEl}
114114
classList={{[styles.Row]: true}}
115115
title={i18n('PasscodeLock.AutoLock')}
116-
// icon="lockoff"
117-
rightContent={<InlineSelect
118-
value={value()}
119-
onClose={() => setIsOpen(false)}
120-
options={options}
121-
onChange={setValue}
122-
isOpen={isOpen()}
123-
parent={autoCloseRowEl()}
124-
/>}
116+
rightContent={
117+
<InlineSelect
118+
value={value()}
119+
onClose={() => setIsOpen(false)}
120+
options={options}
121+
onChange={setValue}
122+
isOpen={isOpen()}
123+
parent={autoCloseRowEl()}
124+
/>
125+
}
125126
clickable={(e) => {
126127
setIsOpen(true);
127128
console.log('setting isOpen to true');

‎src/components/sidebarLeft/tabs/passcodeLock/shortcutBuilder.module.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@
2626
font-size: 12px;
2727
font-weight: 500;
2828

29+
:global(.tgico) {
30+
font-size: 20px;
31+
}
32+
2933
border-radius: 2px;
3034

3135
color: white;
3236
// background-color: #e0e3e5;
33-
background-color: hsl(from var(--secondary-color) h s calc(l + 7));
37+
background-color: hsl(from var(--secondary-color) h s calc(l + 8));
3438

3539
transition: background-color 0.2s;
3640

‎src/components/sidebarLeft/tabs/passcodeLock/shortcutBuilder.tsx

+27-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {Component, createSelector} from 'solid-js';
1+
import {Component, createSelector, JSX} from 'solid-js';
2+
3+
import {IS_APPLE} from '../../../../environment/userAgent';
24

35
import {IconTsx} from '../../../iconTsx';
46
import ripple from '../../../ripple'; // keep
@@ -17,6 +19,28 @@ const ShortcutBuilder: Component<{
1719
}> = (props) => {
1820
const isSelected = createSelector(() => props.value, (value: ShortcutKey, shortcuts) => shortcuts.includes(value));
1921

22+
const getKeyContent = (key: ShortcutKey): JSX.Element => {
23+
if(key === 'Meta') {
24+
return <IconTsx icon={IS_APPLE ? 'mac_command_key' : 'win_key'} />;
25+
}
26+
return <span>{key}</span>;
27+
};
28+
29+
const onKeyClick = (key: ShortcutKey) => {
30+
if(props.value.includes(key)) {
31+
const newValue = props.value.filter((k) => k !== key);
32+
33+
if(!newValue.length) {
34+
const indicies = [0, 1, 2, 3].filter((i) => i !== shortcutKeys.indexOf(key));
35+
newValue.push(shortcutKeys[indicies[Math.floor(Math.random() * indicies.length)]]);
36+
}
37+
38+
props.onChange(newValue);
39+
} else {
40+
props.onChange([...props.value, key]);
41+
}
42+
};
43+
2044
return (
2145
<div class={styles.Container}>
2246
<div class={styles.KeysContainer}>
@@ -25,22 +49,9 @@ const ShortcutBuilder: Component<{
2549
use:ripple
2650
class={styles.KeyButton}
2751
classList={{[styles.selected]: isSelected(key)}}
28-
onClick={() => {
29-
if(props.value.includes(key)) {
30-
const newValue = props.value.filter((k) => k !== key);
31-
if(!newValue.length) {
32-
const indicies = [0, 1, 2, 3].filter((i) => i !== shortcutKeys.indexOf(key));
33-
newValue.push(shortcutKeys[indicies[Math.floor(Math.random() * indicies.length)]]);
34-
}
35-
props.onChange(newValue);
36-
} else {
37-
props.onChange([...props.value, key]);
38-
}
39-
}}
52+
onClick={[onKeyClick, key]}
4053
>
41-
<span>
42-
{key}
43-
</span>
54+
{getKeyContent(key)}
4455
</button>
4556
))}
4657
</div>

0 commit comments

Comments
 (0)