Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Feature/refactoring #137

Merged
merged 32 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bd2d106
chore: refactor structure
yzhe819 Nov 29, 2021
eb0cf4f
chore: remove unused NFTItem imports
yzhe819 Nov 29, 2021
0d26a14
refactor: responsive footprint item components
yzhe819 Nov 29, 2021
11b0b0d
add: animation of address copy
yzhe819 Nov 29, 2021
f6bd185
chore: refactor component structure
yzhe819 Nov 29, 2021
ca5c22c
chore: remove duplicate interface and add details components
yzhe819 Nov 29, 2021
00ec966
refactor: encapsulate common methods about assets (WIP)
yzhe819 Nov 29, 2021
39e466a
add: id typing of `GrantInfo`
AmagiDDmxh Nov 30, 2021
71ae899
add: grants url on details page
AmagiDDmxh Nov 30, 2021
66affbd
refactor: remove getAddress method and fix order pattern
yzhe819 Nov 30, 2021
d51fc92
Merge pull request #135 from AmagiDDmxh/feature/links
Candinya Dec 1, 2021
cb495d8
add: header component
yzhe819 Dec 1, 2021
10c69fe
add: set theme method
yzhe819 Dec 1, 2021
b20bec2
add: init accounts (wip)
yzhe819 Dec 1, 2021
799ab1f
chore: refractor NFTItems
Candinya Dec 1, 2021
27ec7f3
chore: fix mainUrl and optimize variable class
Candinya Dec 1, 2021
4c1f965
fix: model NFT caused overflow
Candinya Dec 1, 2021
9722cdb
refactor: optimize account and asset init
yzhe819 Dec 2, 2021
373b0cf
chore: remove test page
yzhe819 Dec 2, 2021
28fc40b
Merge pull request #136 from NaturalSelectionLabs/feature/refractor-N…
yzhe819 Dec 2, 2021
b3eef4d
chore: remove unused class name and update item style
yzhe819 Dec 2, 2021
fc72263
refactor: optimize tag order preservation
yzhe819 Dec 2, 2021
09806e0
refactor: setup and edit profile page
yzhe819 Dec 2, 2021
a706dda
fix: layout style
yzhe819 Dec 3, 2021
014581b
add: transparent card component
yzhe819 Dec 3, 2021
44e46ed
chore: remove test page
yzhe819 Dec 6, 2021
20789bd
fix: Gitcoin item display
yzhe819 Dec 6, 2021
9abff34
add: vuedraggable animation
yzhe819 Dec 6, 2021
5a264ee
fix: remove comma separator
yzhe819 Dec 6, 2021
fb77c96
Merge branch 'develop' into feature/refactoring
yzhe819 Dec 8, 2021
8f3b51e
Merge branch 'develop' into feature/refactoring
yzhe819 Dec 9, 2021
4ee06db
fix: video url
yzhe819 Dec 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
99 changes: 99 additions & 0 deletions src/common/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @return Array The HSL representation
* @param r
* @param g
* @param b
*/
export function rgbToHsl(r: number, g: number, b: number): [number, number, number] {
r /= 255;
g /= 255;
b /= 255;

const max = Math.max(r, g, b),
min = Math.min(r, g, b);
let h,
s,
l = (max + min) / 2;

if (max == min) {
h = s = 0; // achromatic
} else {
const d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);

switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
default:
h = 0;
break;
}

h /= 6;
}

return [h, s, l];
}

/**
* Converts an HSL color value to RGB. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes h, s, and l are contained in the set [0, 1] and
* returns r, g, and b in the set [0, 255].
*
* @return Array The RGB representation
* @param h
* @param s
* @param l
*/
export function hslToRgb(h: number, s: number, l: number): [number, number, number] {
let r, g, b;

if (s == 0) {
r = g = b = l; // achromatic
} else {
function hue2rgb(p: number, q: number, t: number) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1 / 6) return p + (q - p) * 6 * t;
if (t < 1 / 2) return q;
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
return p;
}

const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;

r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}

return [r * 255, g * 255, b * 255];
}

export function hex2rgb(hex: string): [number, number, number] {
const res = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return res ? [parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16)] : [0, 0, 0];
}

export function rgb2hex(r: number, g: number, b: number) {
return (
'#' +
Math.round((1 << 24) + (r << 16) + (g << 8) + b)
.toString(16)
.slice(1)
);
}
14 changes: 14 additions & 0 deletions src/common/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import RSS3 from '@/common/rss3';
import { RSS3Asset } from 'rss3-next/types/rss3';

const setupTheme = (assets: RSS3Asset[]) => {
// Setup theme
const themes = RSS3.getAvailableThemes(assets);
if (themes[0]) {
document.body.classList.add(themes[0].class);
} else {
document.body.classList.remove(...document.body.classList);
}
};

export default setupTheme;
16 changes: 15 additions & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface GitcoinResponse {
export interface NFT extends Asset {
token_id: string;
name?: string;
chain: 'BSC' | 'Ethereum' | 'Polygon';
description?: string | null;
image_url?: string | null;
image_preview_url?: string | null;
Expand All @@ -39,6 +40,7 @@ export interface NFT extends Asset {
}

export interface GrantInfo {
id?: string;
active: boolean;
title?: string;
slug?: string;
Expand All @@ -54,12 +56,15 @@ export interface GrantInfo {

export interface DonationInfo {
donor: string;
adminAddr?: string;
tokenAddr: string;
amount: string;
symbol?: string;
decimals?: number;
formatedAmount?: string;
timeStamp: string;
txHash: string;
approach?: 'zkSync' | 'Standard';
}

export interface DonationDetailByGrant {
Expand Down Expand Up @@ -105,7 +110,7 @@ export interface GeneralAsset {
animation_original_url?: string | null;
title?: string;
total_contribs?: number;
token_contribs: {
token_contribs?: {
token: string;
amount: string;
}[];
Expand All @@ -119,3 +124,12 @@ export interface GeneralAsset {
export interface GeneralAssetWithTags extends GeneralAsset {
tags?: string[];
}

export interface Profile {
avatar: string;
username: string;
address: string;
bio: string;
rns?: string;
displayAddress?: string;
}