-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI for deleting table constraints
- Loading branch information
1 parent
0d9130e
commit 2c971b1
Showing
7 changed files
with
151 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.seesaw { | ||
overflow: hidden; | ||
.switcher { | ||
display: flex; | ||
align-items: stretch; | ||
width: 200%; | ||
transition: transform .1s; | ||
> * { | ||
flex-basis: 100%; | ||
} | ||
} | ||
&.isRight .switcher { | ||
transform: translateX(-50%); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script lang="ts"> | ||
export let position: 'left' | 'right' = 'left'; | ||
$: isLeft = position === 'left'; | ||
$: isRight = position === 'right'; | ||
</script> | ||
|
||
<div class="seesaw" class:isLeft class:isRight> | ||
<div class="switcher"> | ||
<div class="left"> | ||
<slot name="left"/> | ||
</div> | ||
<div class="right"> | ||
<slot name="right"/> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<style global lang="scss"> | ||
@import "Seesaw.scss"; | ||
</style> | ||
|
37 changes: 37 additions & 0 deletions
37
mathesar_ui/src/sections/table-view/constraints/TableConstraint.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.table-constraint { | ||
line-height: 1.4; | ||
.view, | ||
.confirm-drop { | ||
padding: 10px 15px; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
.view { | ||
> * + * { | ||
margin-left: 10px; | ||
} | ||
.type { | ||
text-transform: uppercase; | ||
color: #666; | ||
} | ||
.columns { | ||
color: #666; | ||
font-size: 0.9rem; | ||
} | ||
.drop { | ||
color: #f47171; | ||
} | ||
} | ||
|
||
.confirm-drop { | ||
text-align: right; | ||
height: 100%; | ||
.warning-icon { | ||
color: #EEE; | ||
} | ||
.buttons { | ||
margin-top: 5px; | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
mathesar_ui/src/sections/table-view/constraints/TableConstraint.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<script lang="ts"> | ||
import { Icon, Seesaw } from '@mathesar-components'; | ||
import type { Constraint } from "@mathesar/stores/table-data/constraints"; | ||
import { faTrash, faCheck, faArrowLeft, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; | ||
import Button from "@mathesar/components/button/Button.svelte"; | ||
import { createEventDispatcher } from 'svelte'; | ||
const dispatch = createEventDispatcher(); | ||
export let constraint: Constraint; | ||
let isConfirmingDrop = false; | ||
$: columnSummary = constraint.columns.join(', '); | ||
</script> | ||
|
||
<div class="table-constraint" class:isConfirmingDrop> | ||
<Seesaw position={isConfirmingDrop ? 'left' : 'right'}> | ||
|
||
<div class="view" slot="right" > | ||
<div> | ||
<div><span class="name">{constraint.name}</span></div> | ||
<div> | ||
<span class="type">{constraint.type}</span> | ||
<span>•</span> | ||
<span class="columns">{columnSummary}</span> | ||
</div> | ||
</div> | ||
<div> | ||
<Button | ||
on:click={() => isConfirmingDrop = true} | ||
class="drop" | ||
title={`Drop constraint "${constraint.name}"`} | ||
> | ||
<Icon data={faTrash} /> | ||
</Button> | ||
</div> | ||
</div> | ||
|
||
<div class="confirm-drop" slot="left"> | ||
<div class="warning-icon"><Icon data={faExclamationTriangle} size="3em"/></div> | ||
<div> | ||
<div>Drop constaint "<span class="name">{constraint.name}</span>"?</div> | ||
<div class="buttons"> | ||
<Button | ||
size="small" | ||
on:click={() => isConfirmingDrop = false} | ||
class="cancel" | ||
title={`Cancel`} | ||
> | ||
<Icon data={faArrowLeft}/> | ||
<span>Cancel</span> | ||
</Button> | ||
<Button | ||
size="small" | ||
on:click={() => dispatch('drop')} | ||
title={`Confirm drop constraint`} | ||
> | ||
<Icon data={faCheck}/> | ||
<span>Drop</span> | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</Seesaw> | ||
</div> | ||
|
||
<style global lang="scss"> | ||
@import "TableConstraint.scss"; | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters