Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase auth provider icon size on login page #27122

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions services/auth/source/oauth2/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
type Provider interface {
Name() string
DisplayName() string
IconHTML() template.HTML
IconHTML(size int) template.HTML
CustomURLSettings() *CustomURLSettings
}

Expand Down Expand Up @@ -54,14 +54,16 @@ func (p *AuthSourceProvider) DisplayName() string {
return p.sourceName
}

func (p *AuthSourceProvider) IconHTML() template.HTML {
func (p *AuthSourceProvider) IconHTML(size int) template.HTML {
if p.iconURL != "" {
img := fmt.Sprintf(`<img class="gt-object-contain gt-mr-3" width="20" height="20" src="%s" alt="%s">`,
img := fmt.Sprintf(`<img class="gt-object-contain gt-mr-3" width="%d" height="%d" src="%s" alt="%s">`,
size,
size,
html.EscapeString(p.iconURL), html.EscapeString(p.DisplayName()),
)
return template.HTML(img)
}
return p.GothProvider.IconHTML()
return p.GothProvider.IconHTML(size)
}

// Providers contains the map of registered OAuth2 providers in Gitea (based on goth)
Expand Down
6 changes: 3 additions & 3 deletions services/auth/source/oauth2/providers_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ func (b *BaseProvider) DisplayName() string {
}

// IconHTML returns icon HTML for this provider
func (b *BaseProvider) IconHTML() template.HTML {
func (b *BaseProvider) IconHTML(size int) template.HTML {
svgName := "gitea-" + b.name
switch b.name {
case "gplus":
svgName = "gitea-google"
case "github":
svgName = "octicon-mark-github"
}
svgHTML := svg.RenderHTML(svgName, 20, "gt-mr-3")
svgHTML := svg.RenderHTML(svgName, size, "gt-mr-3")
if svgHTML == "" {
log.Error("No SVG icon for oauth2 provider %q", b.name)
svgHTML = svg.RenderHTML("gitea-openid", 20, "gt-mr-3")
svgHTML = svg.RenderHTML("gitea-openid", size, "gt-mr-3")
}
return svgHTML
}
Expand Down
4 changes: 2 additions & 2 deletions services/auth/source/oauth2/providers_openid.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func (o *OpenIDProvider) DisplayName() string {
}

// IconHTML returns icon HTML for this provider
func (o *OpenIDProvider) IconHTML() template.HTML {
return svg.RenderHTML("gitea-openid", 20, "gt-mr-3")
func (o *OpenIDProvider) IconHTML(size int) template.HTML {
return svg.RenderHTML("gitea-openid", size, "gt-mr-3")
}

// CreateGothProvider creates a GothProvider from this Provider
Expand Down
2 changes: 1 addition & 1 deletion templates/user/auth/signin_inner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{{range $key := .OrderedOAuth2Names}}
{{$provider := index $.OAuth2Providers $key}}
<a class="{{$provider.Name}} ui button gt-df gt-ac gt-jc gt-py-3 oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$key}}">
{{$provider.IconHTML}}
{{$provider.IconHTML 28}}
{{$.locale.Tr "sign_in_with_provider" $provider.DisplayName}}
</a>
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion templates/user/auth/signup_inner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{{range $key := .OrderedOAuth2Names}}
{{$provider := index $.OAuth2Providers $key}}
<a class="{{$provider.Name}} ui button gt-df gt-ac gt-jc gt-py-3 oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$key}}">
{{$provider.IconHTML}}
{{$provider.IconHTML 28}}
{{$.locale.Tr "sign_in_with_provider" $provider.DisplayName}}
</a>
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion templates/user/settings/security/accountlinks.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{range $key := .OrderedOAuth2Names}}
{{$provider := index $.OAuth2Providers $key}}
<a class="item" href="{{AppSubUrl}}/user/oauth2/{{$key}}">
{{$provider.IconHTML}}
{{$provider.IconHTML 20}}
{{$provider.DisplayName}}
</a>
{{end}}
Expand Down