Skip to content

Commit

Permalink
💄 style(search-bar): 搜索框适配暗色模式
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 26, 2021
1 parent a54d31d commit 24fd36a
Show file tree
Hide file tree
Showing 8 changed files with 1,220 additions and 153 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
@import '~theme/index';

.container {
padding: 8px 12px;
display: flex;
user-select: none;
justify-content: space-between;
padding: 8px 12px;
user-select: none;
}

.option {
background: @search-bar-options-tag-bg;
padding: 2px 6px;
background: @search-bar-options-tag-bg;
border-radius: 2px;
cursor: pointer;
transition: all 150ms ease-in-out;
}

.optionActive {
background: @yuque-brand-color-light;
color: @yuque-brand-color-dark;
background: @yuque-brand-color-light;
}

[theme='dark'] {
.option {
background: @dark-mode-background-dark;
}
.optionActive {
color: @dark-mode-yuque-brand-color-dark;
background: @dark-mode-yuque-brand-color-light;
}
}
11 changes: 11 additions & 0 deletions src/contentScripts/searchBar/app/SearchInput/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@
box-shadow: none !important;
}
}

[theme='dark'] {
.input {
.dark-mode-card-light;
.dark-mode-text-color-base;

&::placeholder {
.dark-mode-text-color-second;
}
}
}
19 changes: 14 additions & 5 deletions src/contentScripts/searchBar/app/SearchResult/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
padding: 8px 12px 24px;
}
.repo {
margin-right: 8px;
width: 24px;
margin-right: 8px;
}
.title {
font-size: 16px;
margin-bottom: 8px;
font-size: 16px;
em {
color: @yuque-brand-color;
font-style: normal;
font-weight: bold;
font-style: normal;
}
}

Expand All @@ -21,14 +21,23 @@
}

.row {
cursor: pointer;
display: flex;
padding: 12px;
cursor: pointer;
transition: background-color 300ms ease-in-out;
display: flex;
}

[theme='light'] {
.row:hover {
background: @item-hover-bg;
}
}

[theme='dark'] {
.desc {
.dark-mode-text-color-second;
}
.row:hover {
background: @dark-mode-background-light-hover;
}
}
2 changes: 1 addition & 1 deletion src/contentScripts/searchBar/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const SearchBar: FC = () => {

export default () => (
<YuqueTokenService.Provider value={useYuqueTokenService()}>
<SearchBarService.Provider value={useSearchBarService()}>
<SearchBarService.Provider value={useSearchBarService(true)}>
<SearchService.Provider value={useSearchService()}>
<SearchBar />
</SearchService.Provider>
Expand Down
23 changes: 18 additions & 5 deletions src/contentScripts/searchBar/app/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
transform: translate(-50%, -50%);
}
.input {
.search-bar-shadow;

background: @background-color-base;
border-radius: 4px;

.search-bar-shadow;
}
.result {
margin-top: 8px;
Expand All @@ -32,18 +31,32 @@
.invalid {
width: 500px;
padding: 24px;
background: @white;
border-radius: 4px;

.flex-center-children;
}
[theme='light'] {
.result {
background: white;
background: @white;
}
.invalid {
background: @white;
}
.input {
background: @background-color-base;
}
}

[theme='dark'] {
.result {
color: @dark-mode-text-color-base;
background: @dark-mode-background-light;
}
.invalid {
background: @dark-mode-background-light;
}
.input {
color: @dark-mode-text-color-base;
background: @dark-mode-background-base;
}
}
8 changes: 3 additions & 5 deletions src/services/useYuqueTokenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export const useYuqueTokenService = () => {
const [token, setYuqueToken] = useLocalStorageState('PY_YUQUE_TOKEN', '');

const syncToCloudStorage = useCallback(() => {
chrome.storage?.sync.set({ yuque_token: token }, () => {
chrome.storage.sync.get(console.log);
});
chrome.storage?.sync.set({ yuque_token: token });
message.success('保存成功');
}, [token]);

Expand All @@ -29,14 +27,14 @@ export const useYuqueTokenService = () => {
if (valid) return;

try {
const data = await request.get('https://www.yuque.com/api/v2/hello', {
await request.get('https://www.yuque.com/api/v2/hello', {
headers: {
'X-Auth-Token': token || '',
'Access-Control-Allow-Origin': '*',
},
getResponse: true,
});
console.log(data);

setValid(true);
return true;
} catch (e) {
Expand Down
3 changes: 3 additions & 0 deletions src/theme/token/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@

@yuque-brand-color-dark: darken(@yuque-brand-color, 20%);
@yuque-brand-color-light: hsl(@yuque-hue-tone, 49%, 85%);

@dark-mode-yuque-brand-color-dark: darken(@yuque-brand-color, 30%);
@dark-mode-yuque-brand-color-light: hsl(@yuque-hue-tone, 10%, 50%);
Loading

0 comments on commit 24fd36a

Please sign in to comment.