better button gestion and wip room layout
This commit is contained in:
152
srcs/requirements/svelte/api_front/src/pieces/chat/Button.svelte
Normal file
152
srcs/requirements/svelte/api_front/src/pieces/chat/Button.svelte
Normal file
@@ -0,0 +1,152 @@
|
||||
|
||||
<!--
|
||||
<Button bind:layout={layout} new_layout="" my_title="">
|
||||
value
|
||||
</Button>
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
export let my_class = "";
|
||||
export let my_title = "";
|
||||
export let layout = "";
|
||||
export let new_layout = "";
|
||||
|
||||
function update_layout() {
|
||||
layout = new_layout;
|
||||
console.log(layout);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<button class={my_class} on:click={update_layout} title={my_title}>
|
||||
<p><slot></slot></p>
|
||||
</button>
|
||||
|
||||
<style>
|
||||
|
||||
/*
|
||||
- default config
|
||||
- for btn list
|
||||
- for transparent btn
|
||||
- for deactivated btn
|
||||
- for icon
|
||||
- for 3 dots btn
|
||||
- for close btn
|
||||
- for back btn
|
||||
*/
|
||||
|
||||
/* default config
|
||||
*/
|
||||
button {
|
||||
display: flex;
|
||||
padding: 0px;
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
border: none;
|
||||
background-color: rgb(220, 220, 220);
|
||||
}
|
||||
button p {
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
}
|
||||
button:hover {
|
||||
background-color: rgb(200, 200, 200);
|
||||
}
|
||||
button:active {
|
||||
background-color: rgb(190, 190, 190);
|
||||
}
|
||||
|
||||
|
||||
/* for btn list
|
||||
*/
|
||||
button.list:not(:hover) {
|
||||
background-color: rgb(240, 240, 240);
|
||||
}
|
||||
button.list p {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
/* for transparent btn
|
||||
*/
|
||||
button.transparent:not(:hover) {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
/* for deactivated btn
|
||||
*/
|
||||
button.deactivate {
|
||||
background-color: transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
||||
/* for icon
|
||||
*/
|
||||
:global(#chat_box) button.icon p {
|
||||
display: none;
|
||||
}
|
||||
button.icon:not(:hover) {
|
||||
background-color: transparent;
|
||||
}
|
||||
button.icon {
|
||||
width: 30px;
|
||||
height: 100%;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
|
||||
/* for 3 dots btn
|
||||
*/
|
||||
button.dots::after {
|
||||
content: '\2807';
|
||||
font-size: 20px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
text-align: center;
|
||||
transform: translateY(-50%);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
/* for close btn
|
||||
*/
|
||||
button.close::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 1px);
|
||||
left: 5px;
|
||||
width: 20px;
|
||||
height: 2px;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
|
||||
/* for back btn
|
||||
*/
|
||||
button.back::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 6px - 1px);
|
||||
left: 6px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-left: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
|
||||
<!--
|
||||
<Button bind:layout={layout} new_layout="" my_class="" my_id"">
|
||||
value
|
||||
</Button>
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
export let my_id = "";
|
||||
export let my_class = "";
|
||||
export let layout = "";
|
||||
export let new_layout = "";
|
||||
|
||||
function update_layout() {
|
||||
layout = new_layout;
|
||||
console.log(layout);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<button class={my_class} id={my_id} on:click={update_layout}>
|
||||
<p><slot></slot></p>
|
||||
</button>
|
||||
|
||||
<style>
|
||||
|
||||
/* default config
|
||||
*/
|
||||
button {
|
||||
display: flex;
|
||||
padding: 0px;
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
border: none;
|
||||
background-color: rgb(220, 220, 220);
|
||||
}
|
||||
button p {
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
}
|
||||
button:hover {
|
||||
background-color: rgb(200, 200, 200);
|
||||
}
|
||||
button:active {
|
||||
background-color: rgb(190, 190, 190);
|
||||
}
|
||||
|
||||
|
||||
/* for btn list
|
||||
*/
|
||||
button.list:not(:hover) {
|
||||
background-color: rgb(240, 240, 240);
|
||||
}
|
||||
button.list p {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
|
||||
<script lang="ts">
|
||||
import HomeLayout from './Layout_home.svelte';
|
||||
import Button from './Buttons.svelte';
|
||||
import RoomLayout from './Layout_room.svelte';
|
||||
import Button from './Button.svelte';
|
||||
|
||||
export let color = "transparent";
|
||||
|
||||
let room = "";
|
||||
let admin = false;
|
||||
let last_layout = "";
|
||||
let layout = "close";
|
||||
|
||||
// hold previous versions of layout, to go back
|
||||
let layouts = [""];
|
||||
function set_layouts(layout)
|
||||
{
|
||||
layouts = [layout, ...layouts];
|
||||
}
|
||||
$: set_layouts(layout);
|
||||
|
||||
/*
|
||||
layout close
|
||||
layout home
|
||||
@@ -31,11 +39,11 @@
|
||||
<HomeLayout bind:layout />
|
||||
|
||||
{:else if layout === "room"}
|
||||
<RoomLayout bind:layout />
|
||||
<RoomLayout bind:layout back={layouts[1]} />
|
||||
|
||||
{:else}
|
||||
<div class="grid_box">
|
||||
<Button bind:layout new_layout="home" my_id="chat">
|
||||
<Button bind:layout new_layout="home" my_class="chat">
|
||||
chat
|
||||
</Button>
|
||||
</div>
|
||||
@@ -65,7 +73,7 @@
|
||||
|
||||
/* style if chat_box is closed
|
||||
*/
|
||||
#chat_box #chat {grid-area: chat;}
|
||||
#chat_box .chat {grid-area: chat;}
|
||||
#chat_box.close .grid_box {
|
||||
gap: 0px;
|
||||
grid:
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
|
||||
<script>
|
||||
import Button from './Buttons.svelte';
|
||||
import Button from './Button.svelte';
|
||||
export let layout;
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
|
||||
<Button bind:layout new_layout="settings" my_id="settings">
|
||||
<Button bind:layout new_layout="settings" my_class="settings dots icon">
|
||||
settings
|
||||
</Button>
|
||||
<Button bind:layout new_layout="new" my_id="new">
|
||||
<Button bind:layout new_layout="new" my_class="new transparent">
|
||||
new
|
||||
</Button>
|
||||
<Button bind:layout new_layout="close" my_id="close">
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
<div class="chat_panel" id="panel_home">
|
||||
<div class="chat_panel panel_home">
|
||||
<p class="title">list of your rooms :</p>
|
||||
<div class="room_list" id="chat_api_room_list">
|
||||
<div class="__show_if_only_child">
|
||||
@@ -29,10 +29,10 @@
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
another room
|
||||
</Button>
|
||||
------------- -->
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
placeholder
|
||||
</Button>
|
||||
------------- -->
|
||||
<!-- END placeholders -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -43,10 +43,10 @@
|
||||
|
||||
/* grid layout "home"
|
||||
*/
|
||||
.grid_box :global(#settings ) {grid-area: settings;}
|
||||
.grid_box :global(#close ) {grid-area: close;}
|
||||
.grid_box :global(#new ) {grid-area: new;}
|
||||
.grid_box :global(#panel_home) {grid-area: panel_home;}
|
||||
.grid_box :global(.settings ) {grid-area: settings;}
|
||||
.grid_box :global(.close ) {grid-area: close;}
|
||||
.grid_box :global(.new ) {grid-area: new;}
|
||||
.grid_box :global(.panel_home) {grid-area: panel_home;}
|
||||
.grid_box {
|
||||
grid:
|
||||
' settings new close ' auto
|
||||
@@ -55,70 +55,15 @@
|
||||
}
|
||||
|
||||
|
||||
/* button "settings" as 3 dots
|
||||
*/
|
||||
.grid_box :global(button#settings p) {
|
||||
display: none;
|
||||
}
|
||||
.grid_box :global(button#settings) {
|
||||
width: 30px;
|
||||
height: 100%;
|
||||
}
|
||||
.grid_box :global(button#settings:not(:hover)) {
|
||||
background-color: transparent;
|
||||
}
|
||||
.grid_box :global(button#settings::after) {
|
||||
content: '\2807';
|
||||
font-size: 20px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
text-align: center;
|
||||
transform: translateY(-50%);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
/* button "new"
|
||||
*/
|
||||
.grid_box :global(button#new:not(:hover)) {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
/* button "close"
|
||||
*/
|
||||
.grid_box :global(button#close p) {
|
||||
display: none;
|
||||
}
|
||||
.grid_box :global(button#close) {
|
||||
width: 30px;
|
||||
height: 100%;
|
||||
padding: 0px;
|
||||
background-color: transparent;
|
||||
}
|
||||
.grid_box :global(button#close::before) {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 1px);
|
||||
left: 5px;
|
||||
width: 20px;
|
||||
height: 2px;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
|
||||
/* panel home
|
||||
*/
|
||||
#panel_home {
|
||||
.panel_home {
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
#panel_home p.title {
|
||||
.panel_home p.title {
|
||||
margin: 10px auto 0px auto;
|
||||
}
|
||||
#panel_home p.no_chat {
|
||||
.panel_home p.no_chat {
|
||||
margin: 0px auto;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
<script>
|
||||
import Button from './Button.svelte';
|
||||
export let layout = "";
|
||||
export let back = "";
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room_set" my_class="room_name transparent">
|
||||
<room_name>
|
||||
</Button>
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
<Button my_class="send">
|
||||
send
|
||||
</Button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
/* grid layout "home"
|
||||
*/
|
||||
.grid_box :global(.back ) {grid-area: back;}
|
||||
.grid_box :global(.room_name ) {grid-area: room_name;}
|
||||
.grid_box :global(.close ) {grid-area: close;}
|
||||
.grid_box :global(.panel_msg ) {grid-area: panel_msg;}
|
||||
.grid_box :global(.send ) {grid-area: send;}
|
||||
.grid_box :global(.panel_write ) {grid-area: panel_write;}
|
||||
.grid_box {
|
||||
grid:
|
||||
' back room_name room_name close ' auto
|
||||
' panel_msg panel_msg panel_msg panel_msg ' 1fr
|
||||
' panel_write panel_write send send ' auto
|
||||
/ auto 1fr auto auto ;
|
||||
}
|
||||
|
||||
|
||||
/* button "<room_name>" appearance
|
||||
*/
|
||||
#chat_box.room button.chat_room_name {
|
||||
width: auto;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
|
||||
<script>
|
||||
import Button from './Buttons.svelte';
|
||||
export let layout;
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
|
||||
<Button bind:layout new_layout="room_set" my_id="room_name">
|
||||
<room_name>
|
||||
</Button>
|
||||
<Button bind:layout new_layout="close" my_id="close">
|
||||
close
|
||||
</Button>
|
||||
<!-- <button class="btn back_home" onclick="chat_layout('home')" title="go back home"></button> -->
|
||||
<Button bind:layout new_layout="home" my_id="back_home">
|
||||
close
|
||||
</Button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
/* grid layout "home"
|
||||
*/
|
||||
.grid_box :global(#back ) {grid-area: back;}
|
||||
.grid_box :global(#room_name ) {grid-area: room_name;}
|
||||
.grid_box :global(#close ) {grid-area: close;}
|
||||
.grid_box :global(#panel_msg ) {grid-area: panel_msg;}
|
||||
.grid_box :global(#send ) {grid-area: send;}
|
||||
.grid_box :global(#panel_write ) {grid-area: panel_write;}
|
||||
.grid_box {
|
||||
grid:
|
||||
' back room_name room_name close ' auto
|
||||
' panel_msg panel_msg panel_msg panel_msg ' 1fr
|
||||
' panel_write panel_write send send ' auto
|
||||
/ auto 1fr auto auto ;
|
||||
}
|
||||
|
||||
|
||||
/* back btn
|
||||
*/
|
||||
#chat_box.room .chat_item.chat_back button.back_home {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
|
||||
/* button "<room_name>" appearance
|
||||
*/
|
||||
#chat_box.room button.chat_room_name {
|
||||
width: auto;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
/* BACK
|
||||
*/
|
||||
#chat_box .chat_item.chat_back button {
|
||||
width: 30px;
|
||||
height: 100%;
|
||||
background-color: transparent;
|
||||
display: none;
|
||||
}
|
||||
#chat_box .chat_item.chat_back button::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 6px - 1px);
|
||||
left: 6px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-left: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user