Skip to content

Commit

Permalink
UI Package: refactor (#4529)
Browse files Browse the repository at this point in the history
* Separate styles responsibilities

* Add misssing dependencies

* Intro page added

* formatting fix
  • Loading branch information
PavelLaptev authored Jul 29, 2024
1 parent 16400aa commit 1c6b03e
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 164 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[mdx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
1 change: 1 addition & 0 deletions apps/desktop/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import '@gitbutler/ui/fonts.css';
import '@gitbutler/ui/main.css';
import '../styles.css';
import { PromptService as AIPromptService } from '$lib/ai/promptService';
import { AIService } from '$lib/ai/service';
Expand Down
119 changes: 119 additions & 0 deletions apps/desktop/src/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
.link {
text-decoration: underline;

&:hover {
text-decoration: none;
}
}

body {
color: var(--clr-text-1);
background-color: var(--clr-bg-2);
}

/**
* Prevents elements within drop-zones from firing mouse events, making
* it much easier to manage in/out/over/leave events since they fire less
* frequently.
*/
.drop-zone-hover * {
pointer-events: none;
}

/* FOCUS STATE */
.focus-state {
&:focus-within {
outline: 1px solid transaparent;
animation: focus-animation var(--transition-fast) forwards;
}
}

@keyframes focus-animation {
0% {
outline-offset: 0;
}
100% {
outline-offset: 2px;
outline: 1px solid var(--focus-color);
}
}

/* CODE */
.code-string {
font-family: var(--mono-font-family);
border-radius: var(--radius-s);
background: var(--clr-scale-ntrl-80);
padding: 1px 4px;
}

/* TRANSITION ANIMATION */

.transition-fly {
animation: transition-fly 0.25s forwards ease-in-out;
}

@keyframes transition-fly {
0% {
transform: translateY(6px);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}

/* STATES */

.wiggle {
animation: wiggle-animation 0.35s forwards;
}

@keyframes wiggle-animation {
0% {
transform: translateX(-3px);
}
25% {
transform: translateX(3px);
}
50% {
transform: translateX(-2px);
}
75% {
transform: translateX(2px);
}
100% {
transform: translateX(0);
}
}

.locked-file-animation {
--locked-color: oklch(from var(--clr-scale-warn-50) l c h / 0.2);
border: 1px solid var(--clr-bg-1);
animation: locked-file-animation 1.4s ease-out forwards;
}

@keyframes locked-file-animation {
0% {
transform: translateX(-3px);
background-color: var(--clr-bg-1);
}
10% {
transform: translateX(3px);
background-color: var(--locked-color);
}
15% {
transform: translateX(-3px);
}
25% {
transform: translateX(3px);
background-color: var(--locked-color);
}
30%,
70% {
transform: translateX(0);
}
100% {
background-color: var(--clr-bg-1);
}
}
2 changes: 2 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
"storybook:build": "storybook build"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
"@csstools/postcss-bundler": "^1.0.15",
"@csstools/postcss-minify": "^1.1.5",
"@storybook/addon-docs": "^8.2.6",
"@storybook/addon-essentials": "^8.1.10",
"@storybook/addon-interactions": "^8.1.10",
"@storybook/addon-links": "^8.1.10",
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/stories/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Meta } from '@storybook/addon-docs';

<Meta title="About/Introduction" />

# 🤖 Welcome to GitButler UI

<img src="https://i.imgflip.com/39lzga.jpg" alt="" />
3 changes: 0 additions & 3 deletions packages/ui/src/styles/core/reset.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
margin: 0;
line-height: inherit;

color: var(--clr-text-1);
background-color: var(--clr-bg-2);

/* optimise font rendering */
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
Expand Down
162 changes: 1 addition & 161 deletions packages/ui/src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/* UTILITY */
@import './utility/text.css';
@import './utility/helpers.css';

/* SHARABLE */
@import './sharable/card.css';
Expand All @@ -20,164 +21,3 @@

/* LAYERS PRIORITY */
@layer reset, sharable;

/* scrollbar helpers */
.hide-native-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;

&::-webkit-scrollbar {
display: none;
}
}

.truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

/* custom scrollbar */
.scrollbar,
pre {
&::-webkit-scrollbar {
background-color: transaparent;
width: 14px;
}

&::-webkit-scrollbar-track {
background-color: transaparent;
}

&::-webkit-scrollbar-thumb {
background-color: var(--clr-border-1);
background-clip: padding-box;
border-radius: 12px;
border: 4px solid rgba(0, 0, 0, 0);
opacity: 0.3;
}

&::-webkit-scrollbar-thumb:hover {
opacity: 0.8;
}

&::-webkit-scrollbar-button {
display: none;
}
}

.link {
text-decoration: underline;

&:hover {
text-decoration: none;
}
}

/**
* Prevents elements within drop-zones from firing mouse events, making
* it much easier to manage in/out/over/leave events since they fire less
* frequently.
*/
.drop-zone-hover * {
pointer-events: none;
}

/* FOCUS STATE */

.focus-state {
&:focus-within {
outline: 1px solid transaparent;
animation: focus-animation var(--transition-fast) forwards;
}
}

@keyframes focus-animation {
0% {
outline-offset: 0;
}
100% {
outline-offset: 2px;
outline: 1px solid var(--focus-color);
}
}

/* CODE */
.code-string {
font-family: var(--mono-font-family);
border-radius: var(--radius-s);
background: var(--clr-scale-ntrl-80);
padding: 1px 4px;
}

/* TRANSITION ANIMATION */

.transition-fly {
animation: transition-fly 0.25s forwards ease-in-out;
}

@keyframes transition-fly {
0% {
transform: translateY(6px);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}

/* STATES */

.wiggle {
animation: wiggle-animation 0.35s forwards;
}

@keyframes wiggle-animation {
0% {
transform: translateX(-3px);
}
25% {
transform: translateX(3px);
}
50% {
transform: translateX(-2px);
}
75% {
transform: translateX(2px);
}
100% {
transform: translateX(0);
}
}

.locked-file-animation {
--locked-color: oklch(from var(--clr-scale-warn-50) l c h / 0.2);
border: 1px solid var(--clr-bg-1);
animation: locked-file-animation 1.4s ease-out forwards;
}

@keyframes locked-file-animation {
0% {
transform: translateX(-3px);
background-color: var(--clr-bg-1);
}
10% {
transform: translateX(3px);
background-color: var(--locked-color);
}
15% {
transform: translateX(-3px);
}
25% {
transform: translateX(3px);
background-color: var(--locked-color);
}
30%,
70% {
transform: translateX(0);
}
100% {
background-color: var(--clr-bg-1);
}
}
44 changes: 44 additions & 0 deletions packages/ui/src/styles/utility/helpers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* scrollbar helpers */
.hide-native-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;

&::-webkit-scrollbar {
display: none;
}
}

/* custom scrollbar */
.scrollbar,
pre {
&::-webkit-scrollbar {
background-color: transaparent;
width: 14px;
}

&::-webkit-scrollbar-track {
background-color: transaparent;
}

&::-webkit-scrollbar-thumb {
background-color: var(--clr-border-1);
background-clip: padding-box;
border-radius: 12px;
border: 4px solid rgba(0, 0, 0, 0);
opacity: 0.3;
}

&::-webkit-scrollbar-thumb:hover {
opacity: 0.8;
}

&::-webkit-scrollbar-button {
display: none;
}
}

.truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Loading

0 comments on commit 1c6b03e

Please sign in to comment.