Skip to content

Commit

Permalink
Merge pull request #404 from carbon-bond/refactor-title-system
Browse files Browse the repository at this point in the history
增加站方代表圖標
  • Loading branch information
MROS authored Jun 1, 2022
2 parents e1ad4f8 + 7a63349 commit a8bbd86
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
5 changes: 5 additions & 0 deletions frontend/src/css/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ declare module '*.png' {
export default value;
}

declare module '*.svg' {
const value: string;
export default value;
}

declare module '*.mp3' {
const value: string;
export default value;
Expand Down
16 changes: 4 additions & 12 deletions frontend/src/css/user_page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,21 @@
& .item {
margin: 0px 0px 5px;
}
& .titleLawyer {
& .titleBlock {
background-color: var(--lighter-gray);
border-radius: 3px;
display: inline-block;
padding: 2px 5px 2px 2px;
& .titleLawyerImage {
background-image: url('/src/img/Q_lawyer.png');
background-size: 16px;
display: inline-block;
& .titleImage {
width: 16px;
height: 16px;
vertical-align: middle;
}
& .titleLawyerText {
& .titleText {
margin-left: 4px;
vertical-align: middle;
}
}
& .titleUnknown {
background-color: var(--lighter-gray);
border-radius: 3px;
display: inline-block;
padding: 2px 5px 2px 2px;
}
}

}
Expand Down
File renamed without changes
Binary file added frontend/src/img/title/站方代表.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 17 additions & 11 deletions frontend/src/tsx/profile/user_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,24 @@ function Sentence(props: { is_me: boolean, sentence: string, setSentence: ((sent
}
}

function CertificationItem(props: { title: string }) : JSX.Element {
if (props.title === '律師') {
return <span className={style.titleLabel}>
<span className={style.titleLawyer}>
<span className={style.titleLawyerImage}/> <span className={style.titleLawyerText}>{props.title}</span>
</span>
</span>;
}
import 律師圖標 from '../../img/title/律師.png';
import 站方代表圖標 from '../../img/title/站方代表.png';

const TITLE_IMAGE_MAPPING: {[index: string]: string} = {
'律師': 律師圖標,
'站方代表': 站方代表圖標
};

function CertificationItem(props: { title: string }) : JSX.Element {
let image_url = TITLE_IMAGE_MAPPING[props.title];
return <span className={style.titleLabel}>
<span className={style.titleUnknown}>
{props.title}
<span className={style.titleBlock}>
{
image_url ?
<img src={image_url} className={style.titleImage} /> :
<></>
}
<span className={style.titleText}>{props.title}</span>
</span>
</span>;
}
Expand Down Expand Up @@ -193,7 +199,7 @@ export function ProfileDetail(props: { profile_user: User }): JSX.Element {
</div>
: props.profile_user.titles.split(',').map(title => (
<CertificationItem title={title} key={`key-${title}`}/>
<CertificationItem title={title} key={`${title}`}/>
))}
</div>
</div>
Expand Down

0 comments on commit a8bbd86

Please sign in to comment.