Skip to content

Commit

Permalink
Remove fomantic image module (go-gitea#21145)
Browse files Browse the repository at this point in the history
Remove this small, but unnecessary
[module](https://fomantic-ui.com/elements/image.html) and use `img`
selector over previous `.image`. Did a few tests, could not notice any
visual regression.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
  • Loading branch information
3 people authored Sep 12, 2022
1 parent fe73246 commit afdab9d
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 382 deletions.
6 changes: 3 additions & 3 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ func SVG(icon string, others ...interface{}) template.HTML {

// Avatar renders user avatars. args: user, size (int), class (string)
func Avatar(item interface{}, others ...interface{}) template.HTML {
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image vm", others...)
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar vm", others...)

switch t := item.(type) {
case *user_model.User:
Expand Down Expand Up @@ -662,7 +662,7 @@ func AvatarByAction(action *activities_model.Action, others ...interface{}) temp

// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML {
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar", others...)

src := repo.RelAvatarLink()
if src != "" {
Expand All @@ -673,7 +673,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM

// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
func AvatarByEmail(email, name string, others ...interface{}) template.HTML {
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar", others...)
src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)

if src != "" {
Expand Down
2 changes: 1 addition & 1 deletion templates/base/head_navbar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{end}}
<div class="item brand" style="justify-content: space-between;">
<a href="{{AppSubUrl}}/" aria-label="{{if .IsSigned}}{{.locale.Tr "dashboard"}}{{else}}{{.locale.Tr "home"}}{{end}}">
<img class="ui mini image" width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{.locale.Tr "logo"}}" aria-hidden="true">
<img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{.locale.Tr "logo"}}" aria-hidden="true">
</a>
{{if .IsSigned}}
<a href="{{AppSubUrl}}/notifications" class="tooltip mobile-only" data-content='{{.locale.Tr "notifications"}}'>
Expand Down
8 changes: 4 additions & 4 deletions templates/repo/issue/view_content/attachments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
{{if not (containGeneric $.Content .UUID)}}
{{$hasThumbnails = true}}
{{end}}
<span class="ui image">{{svg "octicon-file"}}</span>
{{svg "octicon-file"}}
{{else}}
<span class="ui image">{{svg "octicon-desktop-download"}}</span>
{{svg "octicon-desktop-download"}}
{{end}}
<span><strong>{{.Name}}</strong></span>
</a>
Expand All @@ -26,12 +26,12 @@

{{if $hasThumbnails}}
<div class="ui clearing divider"></div>
<div class="ui small images thumbnails">
<div class="ui small thumbnails">
{{- range .Attachments -}}
{{if FilenameIsImage .Name}}
{{if not (containGeneric $.Content .UUID)}}
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
<img class="ui image" src="{{.DownloadURL}}" title='{{$.ctx.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
<img src="{{.DownloadURL}}" title='{{$.ctx.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
</a>
{{end}}
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/release/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
</span>
</span>
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
<strong><span class="ui image" title='{{.Name}}'>{{svg "octicon-package" 16 "mr-2"}}</span>{{.Name}}</strong>
<strong>{{svg "octicon-package" 16 "mr-2"}}{{.Name}}</strong>
</a>
</li>
{{end}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/settings/tags.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@
{{$userIDs := .AllowlistUserIDs}}
{{range $.Users}}
{{if contain $userIDs .ID}}
<a class="ui basic image label" href="{{.HomeLink}}">{{avatar . 26}} {{.GetDisplayName}}</a>
<a class="ui basic label" href="{{.HomeLink}}">{{avatar . 26}} {{.GetDisplayName}}</a>
{{end}}
{{end}}
{{if $.Owner.IsOrganization}}
{{$teamIDs := .AllowlistTeamIDs}}
{{range $.Teams}}
{{if contain $teamIDs .ID}}
<a class="ui basic image label" href="{{$.Owner.OrganisationLink}}/teams/{{PathEscape .LowerName}}">{{.Name}}</a>
<a class="ui basic label" href="{{$.Owner.OrganisationLink}}/teams/{{PathEscape .LowerName}}">{{.Name}}</a>
{{end}}
{{end}}
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion templates/status/404.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="page-content ui container center full-screen-width {{if .IsRepo}}repository{{end}}">
{{if .IsRepo}}{{template "repo/header" .}}{{end}}
<div class="ui container center">
<p style="margin-top: 100px"><img class="ui centered image" src="{{AssetUrlPrefix}}/img/404.png" alt="404"/></p>
<p style="margin-top: 100px"><img src="{{AssetUrlPrefix}}/img/404.png" alt="404"/></p>
<div class="ui divider"></div>
<br>
<p>{{.locale.Tr "error404" | Safe}}
Expand Down
2 changes: 1 addition & 1 deletion templates/status/500.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{template "base/head" .}}
<div class="page-content ui container full-screen-width center">
<p style="margin-top: 100px"><img class="ui centered image" src="{{AssetUrlPrefix}}/img/500.png" alt="500"/></p>
<p style="margin-top: 100px"><img src="{{AssetUrlPrefix}}/img/500.png" alt="500"/></p>
<div class="ui divider"></div>
<br>
{{if .ErrorMsg}}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/example.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('Test Register Form', async ({page}, workerInfo) => {
await page.click('form button.ui.green.button:visible');
// Make sure we routed to the home page. Else login failed.
await expect(page.url()).toBe(`${workerInfo.project.use.baseURL}/`);
await expect(page.locator('.dashboard-navbar span>img.ui.avatar.image')).toBeVisible();
await expect(page.locator('.dashboard-navbar span>img.ui.avatar')).toBeVisible();
await expect(page.locator('.ui.positive.message.flash-success')).toHaveText('Account was successfully created.');

save_visual(page);
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/utils_e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export async function save_visual(page) {
fullPage: true,
timeout: 20000,
mask: [
page.locator('.dashboard-navbar span>img.ui.avatar.image'),
page.locator('.ui.dropdown.jump.item.tooltip span>img.ui.avatar.image'),
page.locator('.dashboard-navbar span>img.ui.avatar'),
page.locator('.ui.dropdown.jump.item.tooltip span>img.ui.avatar'),
],
});
}
Expand Down
Loading

0 comments on commit afdab9d

Please sign in to comment.