Reverted new GridItem design; now placing 2 buttons

This commit is contained in:
DarkCat09 2023-07-26 12:53:28 +04:00
parent 97c46c0c03
commit 8c3eb5b310
2 changed files with 50 additions and 80 deletions

View file

@ -3,67 +3,69 @@ import SimpleMenu from '../layouts/SimpleMenu.astro';
import Icon from './Icon.astro'; import Icon from './Icon.astro';
export interface Props { export interface Props {
id: string;
title: string; title: string;
text: string; text: string;
url: string; url: string;
width?: number; width?: number; // rem
btnAttr?: Object;
btnIcon?: string;
} }
const { const {
id,
title, text, url, title, text, url,
width = 9, width = 9,
btnAttr = null,
btnIcon = "",
} = Astro.props; } = Astro.props;
// add gi-btn class to the secondary button
if (btnAttr != null) {
btnAttr["class"] = (btnAttr["class"] || "") + " gi-btn";
}
--- ---
<div class="gi" id={id}> <div class="gi">
<div class="gi-row"> <div class="gi-main">
<div class="gi-main"> <span class="icon-wrapper">
<span class="icon-wrapper"> <slot name="icon-primary" />
<slot name="icon-primary" /> </span>
<span class="content" style={{width: `${width}rem`}}>
<span class="title">
<slot name="title">
{title}
</slot>
</span> </span>
<span class="content"> <span class="text">
<span class="title"> <slot name="text">
<slot name="title"> {text}
{title} </slot>
</slot>
</span>
<span class="text">
<slot name="text">
{text}
</slot>
</span>
</span> </span>
</div> </span>
<a href={`#${id}`} class="gi-btn gi-btn-expand">
<span class="icon-wrapper">
<Icon code="&#xf107;" />
</span>
</a>
<a href="#scroll" class="gi-btn gi-btn-close">
<span class="icon-wrapper">
<Icon code="&#xf106;" />
</span>
</a>
</div>
<div class="gi-options">
<SimpleMenu jcc="center">
<slot name="options" />
</SimpleMenu>
</div>
<div class="gi-options gi-note">
<slot name="note" />
</div> </div>
{
btnAttr != null ?
<a {...btnAttr}>
<span class="icon-wrapper">
<Icon code={btnIcon} />
</span>
</a> :
""
}
<a href={url} target="_blank" class="gi-btn">
<span class="icon-wrapper">
<Icon code="&#xf35d;" />
</span>
</a>
</div> </div>
<style lang="less" define:vars={{width: `${width}rem`}}> <style lang="less">
.gi { .gi {
// vertical horizontal // vertical horizontal
padding: 0.4rem 0.6rem; padding: 0.4rem 0.6rem;
display: flex; display: flex;
flex-direction: column; flex-direction: row;
align-items: center;
min-height: 3rem; min-height: 3rem;
border-radius: var(--bdrs); border-radius: var(--bdrs);
@ -71,25 +73,6 @@ const {
&:hover { &:hover {
background: var(--accent-bg); background: var(--accent-bg);
} }
.gi-options { display: none }
.gi-btn-close { display: none }
.gi-btn-expand { display: flex }
&:target {
background: var(--accent-bg);
.gi-options { display: block }
.gi-btn-close { display: flex }
.gi-btn-expand { display: none }
}
}
.gi-row {
display: flex;
flex-direction: row;
align-items: center;
} }
.gi-main { .gi-main {
@ -119,7 +102,7 @@ const {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: var(--width); // width is set above using style={{}}
overflow: hidden; overflow: hidden;
.title { .title {
@ -135,14 +118,13 @@ const {
.gi-btn { .gi-btn {
position: relative; position: relative;
font-size: 1.1rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
.icon-wrapper { .icon-wrapper {
@icon-size: 1.25rem; @icon-size: 1.75rem;
width: @icon-size; width: @icon-size;
font-size: @icon-size; font-size: @icon-size;

View file

@ -1,7 +1,6 @@
--- ---
import GridItem from './GridItem.astro'; import GridItem from './GridItem.astro';
import Icon from './Icon.astro'; import Icon from './Icon.astro';
import MenuItem from './MenuItem.astro';
export interface Props { export interface Props {
app: string; app: string;
@ -15,31 +14,20 @@ export interface Props {
const { const {
app, url, name, icon, app, url, name, icon,
copyName = false, copyName = false,
note = "",
} = Astro.props; } = Astro.props;
--- ---
<GridItem <GridItem
id={`p-${app.toLowerCase()}`}
title={app} text={name} url={url} title={app} text={name} url={url}
width={9.5} width={9.5}
btnIcon="&#xf0c5;"
btnAttr={{
"href": "javascript:void(0)",
"class": "profile-copy",
"data-js": copyName ? name : url,
}}
> >
<Icon code={icon} slot="icon-primary" /> <Icon code={icon} slot="icon-primary" />
<Fragment slot="options">
<MenuItem
name=""
link="javascript:void(0)"
icon="&#xf0c5;"
classes={["profile-copy"]}
datajs={copyName ? name : url}
/>
<MenuItem
name="Open"
link={url}
icon="&#xf360;"
tblank
/>
</Fragment>
</GridItem> </GridItem>
<script> <script>