Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix component list overflow #1129

Merged
merged 2 commits into from
Jan 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/styles/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
--component-name: #1171E8;
--component-brackets-selected: rgba(255, 255, 255, 0.4);
--component-attr: #DB00A9;
--component-highlighted-bg: rgba(0, 0, 0, 0.05);
--component-highlighted-bg: #F2F2F3;
--pill-bg: rgba(0, 0, 0, 0.1);
--pill-bg-active: rgba(255, 255, 255, 0.3);
--warning-text: #735c0f;
Expand Down Expand Up @@ -79,7 +79,7 @@
--component-name: #77BEFF;
--component-brackets-selected: rgba(255, 255, 255, 0.4);
--component-attr: #FE7AE9;
--component-highlighted-bg: rgba(255, 255, 255, 0.075);
--component-highlighted-bg: #333333;
--pill-bg: rgba(255, 255, 255, 0.2);
--pill-bg-active: rgba(255, 255, 255, 0.3);
--warning-text: #8ca3f0;
Expand Down
136 changes: 78 additions & 58 deletions app/styles/component_tree.scss
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
.component-tree-item {
align-items: center;
border-radius: 4px;
color: var(--base12);
display: flex;
font-size: 12px;
margin: 0 3px;
min-height: 22px;
position: relative;

&__action {
align-items: center;
background: transparent;
border: 0;
cursor: pointer;
display: inline-flex;
height: 100%;
margin-left: 10px;
&__actions {
min-height: 22px;
opacity: 0;
padding: 0;
right: var(--unit1);

/**
* __actions is position:sticky so it is always visible and on top.
* Due to margins and padding on various elements, it was
* difficult to keep the background of __actions on top
* of .tree-item text and align with the .tree-item background.
* This pseudo element is 100% of the width of __actions plus
* a little extra to guarantee alignment.
*/
&:after {
border-bottom-right-radius: var(--unit1);
border-top-right-radius: var(--unit1);
bottom: 0;
content: '';
left: calc(var(--unit1) * -1);
position: absolute;
right: calc(var(--unit1) * -1);
top: 0;
}

&:focus {
outline: none;
/**
* __actions is position:sticky so it is always visible and on top.
* :before is a gradient to soften the edge when overlaying text.
*/
&:before {
bottom: 0;
content: '';
left: calc(var(--unit3) * -1);
position: absolute;
top: 0;
width: var(--unit3);
}
}

&.disabled {
cursor: not-allowed;
&__action {
&:focus {
outline: none;
}

polygon,
Expand All @@ -34,40 +53,43 @@
}
}

/**
* This element helps with a visual bug.
* When an item overflows the bounds of the list,
* the item background color clips at the point of the overflow.
* This child of the item has the same background color
* and will extend past the overflow point.
*/
.component-tree-item-background {
min-height: 22px;
}

&:hover {
background-color: var(--base05);
background-color: var(--component-highlighted-bg);

.component-tree-item__action {
opacity: 1;
.component-tree-item-background {
background-color: var(--component-highlighted-bg);
}

.component-tree-item__action.disabled {
opacity: 0.65;
.component-tree-item__actions {
opacity: 1;

&:after {
background-color: var(--component-highlighted-bg);
}

&:before {
background: linear-gradient(to right, var(--transparent), var(--component-highlighted-bg) 75%);
}
}
}
}

.component-tree-item__expand {
align-self: stretch;
cursor: pointer;
padding-left: 3px;
padding-right: 3px;
}

.component-tree-item__tag {
cursor: default;
display: flex;
white-space: nowrap;

.component-name {
color: var(--component-name);
}

.arg-token {
display: flex;
margin-left: 0.5rem;
}

.bracket-token {
color: var(--base09);
}
Expand All @@ -81,10 +103,6 @@
}
}

.component-tree-item--has-instance .component-tree-item__tag {
cursor: pointer;
}

.component-tree-item--selected .component-tree-item__tag {
.component-name,
.bracket-token,
Expand Down Expand Up @@ -123,17 +141,7 @@

/**
* Modifier
* highlighted - children of selected component
*/

.component-tree-item.component-tree-item--highlighted {
background-color: var(--component-highlighted-bg);
border-radius: 0;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally used to subtly highlight children of a selected component. At some point that changed and was being used for the hover state. There was a visible lag.


/**
* Modifier
* selected
* selected - user clicked on component
*/

.component-tree-item.component-tree-item--selected {
Expand All @@ -144,6 +152,22 @@
background: var(--focus);
}

.component-tree-item-background {
background: var(--focus);
}

.component-tree-item__actions {
opacity: 1;

&:after {
background: var(--focus);
}

&:before {
background: linear-gradient(to right, var(--transparent), var(--focus) 75%);
}
}

.component-tree-item__bracket:before,
.component-tree-item__bracket:after {
color: var(--component-backets-selected);
Expand All @@ -159,10 +183,6 @@
fill: var(--focus-text);
}
}

.component-tree-item__action.disabled {
opacity: 0.65;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality went away at some point. 👋

}

.component-tree-item--component {
Expand Down
32 changes: 29 additions & 3 deletions app/styles/utils.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
$units: 0, 1, 2, 3, 4;

.relative { position: relative; }

.sticky {
position: -webkit-sticky;
position: sticky;
}

.right-0 {
right: 0;
}

.flex { display: flex; }
.inline-flex { display: inline-flex; }

.flex-grow { flex-grow: 1; }
.flex-grow-0 { flex-grow: 0; }
.flex-shrink { flex-shrink: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.items-center { align-items: center; }
.self-stretch { align-self: stretch; }

.w-5 { width: var(--unit5); }
.w-6 { width: var(--unit6); }
Expand All @@ -18,10 +31,13 @@ $units: 0, 1, 2, 3, 4;
.w-11 { width: var(--unit11); }
.w-12 { width: var(--unit12); }

.h-full { height: 100%; }

@each $key in $units {
.w-#{$key} { width: var(--unit#{$key}); }
.h-#{$key} { height: var(--unit#{$key}); }

.p-#{$key} { padding: var(--unit#{$key}); }
.pt-#{$key} { padding-top: var(--unit#{$key}); }
.pr-#{$key} { padding-right: var(--unit#{$key}); }
.pb-#{$key} { padding-bottom: var(--unit#{$key}); }
Expand All @@ -37,6 +53,7 @@ $units: 0, 1, 2, 3, 4;
padding-top: var(--unit#{$key});
}

.m-#{$key} { margin: var(--unit#{$key}); }
.mt-#{$key} { margin-top: var(--unit#{$key}); }
.mr-#{$key} { margin-right: var(--unit#{$key}); }
.mb-#{$key} { margin-bottom: var(--unit#{$key}); }
Expand All @@ -53,10 +70,12 @@ $units: 0, 1, 2, 3, 4;
}
}

.border-0 { border-width: 0; }

.rounded-none { border-radius: 0; }
.rounded-sm { border-radius: 0.125rem; }
.rounded { border-radius: 0.25rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-sm { border-radius: calc(var(--unit1) / 2); }
.rounded { border-radius: var(--unit1); }
.rounded-lg { border-radius: var(--unit2); }
.rounded-full { border-radius: 9999px; }

.font-bold { font-weight: bold; }
Expand All @@ -65,7 +84,14 @@ $units: 0, 1, 2, 3, 4;
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.whitespace-no-wrap { white-space: nowrap; }

.bg-transparent { background-color: var(--transparent); }
.bg-base00 { background-color: var(--base00); }
.bg-base01 { background-color: var(--base01); }
.bg-base02 { background-color: var(--base02); }

.cursor-default { cursor: default; }
.cursor-pointer { cursor: pointer; }

.z-10 { z-index: 10; }
Loading