Skip to content

Commit

Permalink
feat: allow admins to prevent the icon in the top left corner from sp… (
Browse files Browse the repository at this point in the history
#4601)

* feat: allow admins to prevent the icon in the top left corner from spinning on hovers

* Add to globals

* Update web/src/globals.d.ts

Conflicts:
	web/src/nav/GlobalNavbar.scss
	web/src/nav/GlobalNavbar.tsx

(addressed manually)
  • Loading branch information
dadlerj authored and slimsag committed Jul 2, 2019
1 parent c55e90e commit f345daf
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ All notable changes to Sourcegraph are documented in this file.
- A new experimental search filter `repohascommitafter:"30 days ago"` allows users to exclude stale repositories that don't contain commits (to the branch being searched over) past a specified date from their search query.
- The `authorization` setting in the [Bitbucket Server external service config](https://docs.sourcegraph.com/admin/external_service/bitbucket_server#permissions) enables Sourcegraph to enforce the repository permissions defined in Bitbucket Server.
- A new, experimental status indicator in the navigation bar allows admins to quickly see whether the configured repositories are up to date or how many are currently being updated in the background. You can enable the status indicator with the following site configuration: `"experimentalFeatures": { "statusIndicator": "enabled" }`.
- A new search filter `repohasfile` allows users to filter results to just repositories containing a matching file. For example `ubuntu file:Dockerfile repohasfile:\.py$` would find Dockerfiles mentioning Ubuntu in repositories that contain Python files. [#4501](https://github.com/sourcegraph/sourcegraph/pull/4501)
- Site admins can prevent the icon in the top-left corner of the screen from spinning on hovers by setting `"branding": { "disableSymbolSpin": true }` in their site configuration.

### Changed

Expand Down
7 changes: 4 additions & 3 deletions schema/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions schema/site.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
"description": "The URL of the favicon to be used for your instance. We recommend using the following file format: ICO",
"type": "string",
"format": "uri"
},
"disableSymbolSpin": {
"description": "Prevents the icon in the top-left corner of the screen from spinning on hover.",
"type": "boolean",
"default": false
}
},
"examples": [
Expand Down
5 changes: 5 additions & 0 deletions schema/site_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions web/src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ interface SourcegraphContext {
light?: BrandAssets
/** Override style for dark themes */
dark?: BrandAssets

/** Prevents the icon in the top-left corner of the screen from spinning. */
disableSymbolSpin?: boolean
}

/** Whether new external service status indicator is shown in navbar or not. */
Expand Down
20 changes: 12 additions & 8 deletions web/src/nav/GlobalNavbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@
}
&:not(&--full) {
width: 1.5rem;
&:hover {
animation: spin 0.5s ease-in-out 1;
}
&--animated {
&:not(&--full) {
&:hover {
animation: spin 0.5s ease-in-out 1;

@keyframes spin {
50% {
transform: rotate(180deg) scale(1.2);
}
@keyframes spin {
50% {
transform: rotate(180deg) scale(1.2);
}

100% {
transform: rotate(180deg) scale(1);
100% {
transform: rotate(180deg) scale(1);
}
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions web/src/nav/GlobalNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class GlobalNavbar extends React.PureComponent<Props, State> {
}

public render(): JSX.Element | null {
const { branding } = window.context
let logoSrc: string
const showFullLogo = this.props.location.pathname === '/welcome'
if (showFullLogo) {
Expand All @@ -88,7 +89,6 @@ export class GlobalNavbar extends React.PureComponent<Props, State> {
: '/.assets/img/sourcegraph-head-logo.svg'
} else {
logoSrc = '/.assets/img/sourcegraph-mark.svg'
const { branding } = window.context
if (branding) {
if (this.props.isLightTheme) {
if (branding.light && branding.light.symbol) {
Expand All @@ -100,8 +100,14 @@ export class GlobalNavbar extends React.PureComponent<Props, State> {
}
}

const animated = !branding || (branding && !branding.disableSymbolSpin)
const logo = (
<img className={`global-navbar__logo ${showFullLogo ? 'global-navbar__logo--full' : ''}`} src={logoSrc} />
<img
className={`global-navbar__logo ${showFullLogo ? 'global-navbar__logo--full' : ''} ${
animated ? 'global-navbar__logo--animated' : ''
}`}
src={logoSrc}
/>
)

return (
Expand Down

0 comments on commit f345daf

Please sign in to comment.