Skip to content

Commit 2419d8d

Browse files
authored
Merge pull request #60 from SolidOS/socials
Add Social Network accounts to your profile
2 parents a179343 + 0188aca commit 2419d8d

25 files changed

+3345
-3636
lines changed

Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

2-
# Wrap ttext files in js as text load is broken
2+
# Wrap text files in js as text load is broken
33

4-
src/editProfilePane/wrapped-profileFormText.ts : src/editProfilePane/profileFormText.ttl
5-
echo "export const profileFormText = \`" > $@
6-
cat src/editProfilePane/profileFormText.ttl >> $@
4+
src/editProfilePane/wrapped-profileFormText.ts : src/ontology/profileForm.ttl src/ontology/socialMedia.ttl
5+
echo "export const profileForm= \`" > $@
6+
cat src/ontology/profileForm.ttl >> $@
7+
cat src/ontology/socialMedia.ttl >> $@
78
echo '` ;' >> $@

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ npm run build
4848
```
4949

5050
The build is done by `tsc`, webpack is only used as dev server and not for production build.
51+
52+
### Check before committing
53+
54+
```
55+
npm run check
56+
```
57+
58+
This does lint, build and test.

dev/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ finishLogin();
2727
// https://timbl.inrupt.net/profile/card#me
2828
//
2929
// const webIdToShow = "https://angelo.veltens.org/profile/card#me";
30-
const webIdToShow = "https://testingsolidos.solidcommunity.net/profile/card#me";
31-
// const webIdToShow = "https://timbl.inrupt.net/profile/card#me";
30+
// const webIdToShow = "https://testingsolidos.solidcommunity.net/profile/card#me";
31+
const webIdToShow = "https://timbl.inrupt.net/profile/card#me";
3232

3333
fetcher.load(webIdToShow).then(() => {
3434
const app = pane.render(sym(webIdToShow), context);

package-lock.json

+1,059-3,606
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"main": "lib/index.js",
1010
"scripts": {
1111
"start": "webpack serve --config webpack.dev.config.js --open",
12-
"build": "npm run clean && tsc",
12+
"build": "make && npm run clean && tsc",
1313
"clean": "rm -rf lib",
1414
"check": "npm run lint && npm run build && npm run test",
1515
"test": "jest",
@@ -36,7 +36,7 @@
3636
"contacts-pane": "^2.6.12",
3737
"lit-html": "^3.1.2",
3838
"qrcode": "^1.5.3",
39-
"solid-ui": "^2.4.33",
39+
"solid-ui": "2.5",
4040
"validate-color": "^2.2.4"
4141
},
4242
"devDependencies": {

src/0Panic.diff

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
diff --git a/src/CVCard.ts b/src/CVCard.ts
2+
index 793e095..8e09a6b 100644
3+
--- a/src/CVCard.ts
4+
+++ b/src/CVCard.ts
5+
@@ -1,14 +1,10 @@
6+
import { html, TemplateResult } from "lit-html";
7+
-import { icons } from "solid-ui";
8+
-
9+
-const editButtonURI = icons.iconBase + 'noun_253504.svg'
10+
-
11+
import {
12+
fullWidth,
13+
heading,
14+
paddingSmall,
15+
textCenter,
16+
- textLeft, textRight,
17+
+ textLeft,
18+
textGray,
19+
} from "./baseStyles";
20+
import { ProfilePresentation } from "./presenter";
21+
@@ -21,7 +17,6 @@ const styles = {
22+
intro: styleMap({ ...textGray(), ...textCenter() }),
23+
card: styleMap(card()),
24+
info: styleMap({ ...paddingSmall(), ...textLeft() }),
25+
- tools: styleMap({ ...paddingSmall(), ...textRight() }),
26+
};
27+
28+
export const CVCard = (
29+
@@ -52,7 +47,6 @@ export const CVCard = (
30+
<div style=${styles.info}>${renderSkills(skills)}</div>
31+
<h3 style=${nameStyle}>Languages</h3>
32+
<div style=${styles.info}>${renderLanguages(languages)}</div>
33+
- <div style=${styles.tools}>${renderEditButton()}</div>
34+
</div>
35+
</div>
36+
`}
37+
@@ -111,9 +105,3 @@ function strToUpperCase(str) {
38+
}
39+
return '';
40+
}
41+
-
42+
-function renderEditButton () {
43+
- return html `<button type="button" class="ProfilePaneCVEditButton">
44+
- <img src="${editButtonURI}">
45+
- Edit</button>`
46+
-}
47+
\ No newline at end of file

src/0SAVED-CVCard.ts

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { html, TemplateResult } from "lit-html";
2+
import {
3+
fullWidth,
4+
heading,
5+
paddingSmall,
6+
textCenter,
7+
textLeft,
8+
textGray,
9+
} from "./baseStyles";
10+
import { ProfilePresentation } from "./presenter";
11+
import { CVPresentation } from "./CVPresenter";
12+
import { styleMap } from "lit-html/directives/style-map.js";
13+
import { card } from "./baseStyles";
14+
15+
const styles = {
16+
image: styleMap(fullWidth()),
17+
intro: styleMap({ ...textGray(), ...textCenter() }),
18+
card: styleMap(card()),
19+
info: styleMap({ ...paddingSmall(), ...textLeft() }),
20+
};
21+
22+
export const CVCard = (
23+
profileBasics: ProfilePresentation,
24+
cvData: CVPresentation
25+
): TemplateResult => {
26+
27+
const { rolesByType, skills, languages } = cvData;
28+
29+
const nameStyle = styleMap({
30+
...heading(),
31+
// "text-decoration": "underline",
32+
color: profileBasics.highlightColor, // was "text-decoration-color"
33+
});
34+
35+
if(renderRoles(rolesByType["FutureRole"]) || renderRoles(rolesByType["CurrentRole"]) || renderRoles(rolesByType["PastRole"]) || renderSkills(skills) || renderLanguages(languages)){
36+
return html`
37+
<div data-testid="curriculum-vitae" style="${styles.card}">
38+
<div style=${styles.info}>
39+
<h3 style=${nameStyle}>Bio</h3>
40+
<div style=${styles.info}>${renderRoles(rolesByType["FutureRole"])}</div>
41+
<hr />
42+
<div style=${styles.info}>${renderRoles(rolesByType["CurrentRole"])}</div>
43+
<hr />
44+
<div style=${styles.info}>${renderRoles(rolesByType["PastRole"])}</div>
45+
<hr />
46+
<h3 style=${nameStyle}>Skills</h3>
47+
<div style=${styles.info}>${renderSkills(skills)}</div>
48+
<h3 style=${nameStyle}>Languages</h3>
49+
<div style=${styles.info}>${renderLanguages(languages)}</div>
50+
</div>
51+
</div>
52+
`}
53+
return html``
54+
}
55+
56+
function renderRole(role) {
57+
return role
58+
? html`<div style="margin-top: 0.3em; margin-bottom: 0.3em;">
59+
<b>${role.orgName}</b>
60+
<span>${strToUpperCase(role.roleText)}</span>
61+
<span>${role.dates}</span>
62+
</div> `
63+
: html``;
64+
}
65+
66+
function renderRoles(roles) {
67+
if (roles[0] > "")
68+
return html`${renderRole(roles[0])}${roles.length > 1 ? renderRoles(roles.slice(1)) : html``}`
69+
}
70+
71+
function renderSkill(skill) {
72+
return skill
73+
? html`<div style="margin: 0.5em;">
74+
<p style="text-align: center;">${skill}</p>
75+
</div> `
76+
: html``;
77+
}
78+
79+
function renderSkills(skills) {
80+
if(skills[0] > "")
81+
return html`${renderSkill(strToUpperCase(skills[0]))} ${skills.length > 1 ? renderSkills(skills.slice(1)) : html``}`
82+
}
83+
84+
function renderLan(language) {
85+
return language
86+
? html`<div style="margin: 0.5em;">
87+
<p style="text-align: center;">${language}</p>
88+
</div> `
89+
: html``;
90+
}
91+
92+
function renderLanguages(languages) {
93+
if(languages[0] > "")
94+
return html`${renderLan(languages[0])}${languages.length > 1 ? renderLanguages(languages.slice(1)) : html``}`
95+
}
96+
97+
function strToUpperCase(str) {
98+
if (str && str[0] > "") {
99+
const strCase = str.split(' ');
100+
for (let i = 0; i < strCase.length; i++) {
101+
strCase[i] = strCase[i].charAt(0).toUpperCase() +
102+
strCase[i].substring(1);
103+
}
104+
return strCase.join(' ');
105+
}
106+
return '';
107+
}

src/CVCard.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import { html, TemplateResult } from "lit-html";
2-
import { icons } from "solid-ui";
3-
4-
const editButtonURI = icons.iconBase + 'noun_253504.svg'
5-
62
import {
73
fullWidth,
84
heading,
@@ -15,6 +11,9 @@ import { ProfilePresentation } from "./presenter";
1511
import { CVPresentation } from "./CVPresenter";
1612
import { styleMap } from "lit-html/directives/style-map.js";
1713
import { card } from "./baseStyles";
14+
import { icons } from "solid-ui";
15+
16+
const editButtonURI = icons.iconBase + 'noun_253504.svg'
1817

1918
const styles = {
2019
image: styleMap(fullWidth()),
@@ -52,7 +51,7 @@ export const CVCard = (
5251
<div style=${styles.info}>${renderSkills(skills)}</div>
5352
<h3 style=${nameStyle}>Languages</h3>
5453
<div style=${styles.info}>${renderLanguages(languages)}</div>
55-
<div style=${styles.tools}>${renderEditButton()}</div>
54+
<div style=${styles.tools}>${renderEditButton()}</div>
5655
</div>
5756
</div>
5857
`}
@@ -113,7 +112,10 @@ function strToUpperCase(str) {
113112
}
114113

115114
function renderEditButton () {
116-
return html `<button type="button" class="ProfilePaneCVEditButton">
117-
<img src="${editButtonURI}">
118-
Edit</button>`
119-
}
115+
return html `<button type="button" class="ProfilePaneCVEditButton">
116+
<img src="${editButtonURI}">
117+
Edit</button>`
118+
}
119+
120+
// ends
121+

src/ProfileView.ts

+4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import { ChatWithMe } from "./ChatWithMe";
1010
import { FriendList } from "./FriendList";
1111
import { presentProfile } from "./presenter";
1212
import { presentCV } from './CVPresenter' // 20210527
13+
import { presentSocial } from './SocialPresenter' // 20210527
1314
import { presentStuff } from './StuffPresenter' // 20210527
1415
import { ProfileCard } from "./ProfileCard";
1516
import { CVCard } from "./CVCard";
17+
import { SocialCard } from "./SocialCard";
1618
import { StuffCard } from "./StuffCard";
1719
import { QRCodeCard } from "./QRCodeCard";
1820
import { addMeToYourFriendsDiv } from "./addMeToYourFriends";
@@ -23,6 +25,7 @@ export async function ProfileView (
2325
): Promise <TemplateResult> {
2426
const profileBasics = presentProfile(subject, context.session.store as LiveStore); // rdflib rdfs type problems
2527
const rolesByType = presentCV (subject, context.session.store as LiveStore)
28+
const accounts = presentSocial(subject, context.session.store as LiveStore)
2629
const stuffData = await presentStuff(subject)
2730
const styles = {
2831
grid: styleMap({
@@ -46,6 +49,7 @@ export async function ProfileView (
4649
</div>
4750
</div>
4851
${CVCard(profileBasics, rolesByType)}
52+
${SocialCard(profileBasics, accounts)}
4953
${StuffCard(profileBasics, context, subject, stuffData)}
5054
${FriendList(profileBasics, subject, context)}
5155
<div style="${styles.chat}">${ChatWithMe(subject, context)}</div>

src/SocialCard.ts

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { html, TemplateResult } from "lit-html";
2+
import {
3+
fullWidth,
4+
heading,
5+
paddingSmall,
6+
textCenter,
7+
textRight,
8+
textGray,
9+
} from "./baseStyles";
10+
import { ProfilePresentation } from "./presenter";
11+
import { SocialPresentation } from "./SocialPresenter";
12+
import { styleMap } from "lit-html/directives/style-map.js";
13+
import { card } from "./baseStyles";
14+
15+
16+
const styles = {
17+
image: styleMap(fullWidth()),
18+
intro: styleMap({ ...textGray(), ...textCenter() }),
19+
card: styleMap(card()),
20+
info: styleMap({ ...paddingSmall(), ...textCenter() }),
21+
tools: styleMap({ ...paddingSmall(), ...textRight() }),
22+
};
23+
24+
export const SocialCard = (
25+
profileBasics: ProfilePresentation,
26+
SocialData: SocialPresentation
27+
): TemplateResult => {
28+
29+
const { accounts } = SocialData;
30+
31+
const nameStyle = styleMap({
32+
...heading(),
33+
// "text-decoration": "underline",
34+
color: profileBasics.highlightColor, // was "text-decoration-color"
35+
});
36+
37+
if(accounts.length){
38+
39+
return html`
40+
<div data-testid="social-media" style="${styles.card}">
41+
<div style=${styles.info + "margin: auto;"}>
42+
<h3 style=${nameStyle}>Follow me on</h3>
43+
44+
<div style=${styles.info}>${renderAccounts(accounts)}</div>
45+
</div>
46+
</div>
47+
`}
48+
return html``
49+
}
50+
51+
function renderAccount(account) {
52+
return account.homepage && account.name && account.icon
53+
? html`<div class="textButton-0-1-3" style="margin-top: 0.3em; margin-bottom: 0.3em;">
54+
55+
<a href="${account.homepage}" style="text-decoration: none;" target="social">
56+
<img style="width: 2em; height: 2em; margin: 1em; vertical-align:middle;" src="${account.icon}" alt="${account.name}">
57+
58+
<span style="font-size: 1.2rem;">${account.name}</span>
59+
</a>
60+
</div> `
61+
: html``;
62+
}
63+
64+
function renderAccounts(accounts) {
65+
if (accounts.length > 0)
66+
return html`${renderAccount(accounts[0])}${accounts.length > 1 ? renderAccounts(accounts.slice(1)) : html``}`
67+
}
68+
69+
// ends
70+

0 commit comments

Comments
 (0)