File tree 2 files changed +53
-2
lines changed
packages/experiments-realm
2 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ export class EmailField extends StringField {
69
69
<template >
70
70
{{#if @ model }}
71
71
<EntityDisplayWithIcon @ title ={{@ model }} @ underline ={{ false }} >
72
+ <: title >
73
+ <a href =' mailto:{{@ model }} ' rel =' noopener noreferrer' >
74
+ {{@ model }}
75
+ </a >
76
+ </: title >
72
77
<: icon >
73
78
<MailIcon class =' icon' />
74
79
</: icon >
@@ -78,6 +83,10 @@ export class EmailField extends StringField {
78
83
.icon {
79
84
color : var (--boxel-400 );
80
85
}
86
+ a :hover {
87
+ text-decoration : underline ;
88
+ color : inherit ;
89
+ }
81
90
< /style >
82
91
</template >
83
92
};
Original file line number Diff line number Diff line change @@ -18,17 +18,59 @@ export class WebsiteField extends UrlField {
18
18
19
19
static atom = class Atom extends Component <typeof WebsiteField > {
20
20
<template >
21
- <EntityDisplayWithIcon @ title ={{domainWithPath @ model}} >
21
+ <EntityDisplayWithIcon >
22
+ <: title >
23
+ {{! Display only domain and path, unlike URLField's full URL representation }}
24
+ {{! Custom atom implementation for handling URL interactions }}
25
+ {{#if @ model }}
26
+ {{#if ( isValidUrl @ model) }}
27
+ <a href ={{@ model }} target =' _blank' rel =' noopener noreferrer' >
28
+ {{domainWithPath @ model}}
29
+ </a >
30
+ {{else }}
31
+ Invalid URL
32
+ {{/if }}
33
+ {{/if }}
34
+ </: title >
22
35
<: icon >
23
36
<WorldWwwIcon />
24
37
</: icon >
25
38
</EntityDisplayWithIcon >
39
+ <style scoped >
40
+ a :hover {
41
+ text-decoration : underline ;
42
+ color : inherit ;
43
+ }
44
+ < /style >
26
45
</template >
27
46
};
28
47
29
48
static embedded = class Embedded extends Component <typeof WebsiteField > {
30
49
<template >
31
- {{domainWithPath @ model}}
50
+ {{#if @ model }}
51
+ {{#if ( isValidUrl @ model) }}
52
+ <a href ={{@ model }} target =' _blank' rel =' noopener noreferrer' >
53
+ {{domainWithPath @ model}}
54
+ </a >
55
+ {{else }}
56
+ Invalid URL
57
+ {{/if }}
58
+ {{/if }}
59
+ <style scoped >
60
+ a :hover {
61
+ text-decoration : underline ;
62
+ color : inherit ;
63
+ }
64
+ < /style >
32
65
</template >
33
66
};
34
67
}
68
+
69
+ function isValidUrl(urlString : string ): boolean {
70
+ try {
71
+ new URL (urlString );
72
+ return true ;
73
+ } catch (err ) {
74
+ return false ;
75
+ }
76
+ }
You can’t perform that action at this time.
0 commit comments