Skip to content

Commit

Permalink
Merge pull request #30 from metastellar-io/codepert
Browse files Browse the repository at this point in the history
add shadow props to frame component.
  • Loading branch information
mymiracle0118 authored Jul 18, 2024
2 parents d4bfb7d + edb32f3 commit d978703
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/lib/frame/frame.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
let divClass;
// $:divClass = twMerge('ms-frame ', $$props.rounded && 'rounded-lg', hoverTransform && "hover", $$props.class, imgHoverTransform && ("img-hover"))
$:divClass = twMerge('ms-frame ', $$props.rounded && 'rounded-lg', $$props.class)
$:divClass = twMerge('ms-frame ', $$props.rounded && 'rounded-lg', $$props.class, $$props.shadow && 'shadow')
</script>

Expand Down
2 changes: 2 additions & 0 deletions src/lib/frame/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.ms-frame {
cursor: pointer;
}
.ms-frame.shadow {
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}
.ms-frame.hover:hover {
Expand Down
14 changes: 14 additions & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Reexport your entry components here

import { normalizeData, renderCanvas } from "./CanvasModal/index.js";
export { default as Card } from "./card/card.svelte";
export { default as AssetSelector } from "./assetSelector/assetSelector.svelte";
export { default as ImagePoster } from "./imagePoster/imagePoster.svelte";
export { default as NftPoster } from "./nftPoster/nftPoster.svelte";
export { default as YoutubePoster } from "./youtubePoster/youtubePoster.svelte";
export { default as CanvasModal } from "./CanvasModal/Modal.svelte";
export { default as Jumbotron } from "./jumbotron/index.svelte";
export { default as TokenPoster } from "./tokenPoster/tokenPoster.svelte";
export * from "./types.js";
export * from "./utility.js";
export { normalizeData, renderCanvas };
35 changes: 20 additions & 15 deletions src/lib/tokenPoster/tokenPoster.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,8 @@
xl: 'p-4 sm:p-8'
};
const yPaddings: Record<SizeType | 'none', string> = {
none: '',
xs: 'py-2',
sm: 'py-4',
md: 'py-4 sm:py-5',
lg: 'py-4 sm:py-6',
xl: 'py-4 sm:py-8'
};
let innerPadding: string;
$: innerPadding = paddings[padding];
let innerYpadding: string;
$: innerYpadding = yPaddings[padding];
let assetInfo: AssetRaw;
let assetMetadata: AssetMetaData;
Expand All @@ -60,6 +49,23 @@
// console.log("token card metadata", assetMetadata);
}
}
function shortenString(str:string, maxLength:number): string {
if (str.length <= maxLength) {
return str; // No need to shorten
} else {
// Calculate lengths of the parts
let firstPartLength = Math.ceil(maxLength / 2);
let secondPartLength = maxLength - firstPartLength;
// Extract the first and last parts
let firstPart = str.substring(0, firstPartLength);
let secondPart = str.substring(str.length - secondPartLength);
// Construct the shortened string
return firstPart + "...." + secondPart;
}
}
const sendAssetInfo = () => {
const data: AssetData = {
Expand All @@ -85,14 +91,13 @@

<Frame tag="div" {...$$restProps} class={cardClass} on:click={() => {sendAssetInfo();}}>
{#if assetMetadata?.image}
<img class={imgCls} src={assetMetadata?.image} alt="product 1" />
<img class={imgCls} src={assetMetadata?.image} alt="product 1" width={100} />
{:else}
<!-- <ImagePlaceholder imgOnly class="mt-12 w-full" style={{width:'100%'}} size="lg"/> -->
<div class="flex justify-center items-center h-10 bg-gray-300 rounded dark:bg-gray-700">
<!-- <div class="flex justify-center items-center w-full h-48 bg-gray-300 rounded dark:bg-gray-700">
<svg width="48" height="48" class="text-gray-200" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" viewBox="0 0 640 512">
<path d="M480 80C480 35.82 515.8 0 560 0C604.2 0 640 35.82 640 80C640 124.2 604.2 160 560 160C515.8 160 480 124.2 480 80zM0 456.1C0 445.6 2.964 435.3 8.551 426.4L225.3 81.01C231.9 70.42 243.5 64 256 64C268.5 64 280.1 70.42 286.8 81.01L412.7 281.7L460.9 202.7C464.1 196.1 472.2 192 480 192C487.8 192 495 196.1 499.1 202.7L631.1 419.1C636.9 428.6 640 439.7 640 450.9C640 484.6 612.6 512 578.9 512H55.91C25.03 512 .0006 486.1 .0006 456.1L0 456.1z" />
</svg>
</div>
</div> -->
{/if}

<div class="flex justify-between w-full mt-2">
Expand Down
16 changes: 15 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
dataURL="http://localhost/api"
intervalData={intervalData}
hoverTransform
shadow
rounded
>
<h5 class="mb-2 text-xl tracking-tight text-gray-900 ">Meta stellar card</h5>
<p class="mb-3 font-normal text-gray-700 leading-tight">Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
Expand All @@ -57,6 +59,8 @@
hoverTransform
imgHoverTransform
reverse
shadow
rounded
>
<h5 class="mb-2 text-xl tracking-tight text-gray-900 ">Meta stellar card(reverse)</h5>
<p class="mb-3 font-normal text-gray-700 leading-tight">Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
Expand All @@ -69,6 +73,8 @@
dataURL="http://localhost/api"
intervalData={intervalData}
hoverTransform
shadow
rounded
>
<h5 class="mb-2 text-xl tracking-tight text-gray-900 ">Meta stellar card(no image)</h5>
<p class="mb-3 font-normal text-gray-700 leading-tight">Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
Expand All @@ -81,7 +87,9 @@
intervalData={intervalData}
hoverTransform
class="rounded-lg"
imgClass="rounded-lg">
imgClass="rounded-lg"
shadow
rounded>
</ImagePoster>
<h3 class="mt-4">
Image poster card
Expand All @@ -92,6 +100,8 @@
yutubeURL="/video/1.mp4"
thumnailURL="/images/1.jpg"
type="video/mp4"
shadow
rounded
>
<div class="">
<a href="/video/1.mp4" class="mt-2">
Expand All @@ -112,6 +122,8 @@
imgHoverTransform
assetAccount={nftInfo}
getNFTAssetInfo={getNFTAssetInfo}
shadow
rounded
>
</NftPoster>

Expand All @@ -130,6 +142,8 @@
imgHoverTransform
assetAccount={tokenInfo}
getTokenAssetInfo={getTokenAssetInfo}
shadow
rounded
>
</TokenPoster>
<h3 class="mt-4">
Expand Down

0 comments on commit d978703

Please sign in to comment.