forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2681 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes up to d702a03
- Loading branch information
Showing
60 changed files
with
2,167 additions
and
1,232 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// This file will be loaded on embed pages, regardless of theme. | ||
|
||
import 'packs/public-path'; | ||
import ready from '../mastodon/ready'; | ||
|
||
interface SetHeightMessage { | ||
type: 'setHeight'; | ||
id: string; | ||
height: number; | ||
} | ||
|
||
function isSetHeightMessage(data: unknown): data is SetHeightMessage { | ||
if ( | ||
data && | ||
typeof data === 'object' && | ||
'type' in data && | ||
data.type === 'setHeight' | ||
) | ||
return true; | ||
else return false; | ||
} | ||
|
||
window.addEventListener('message', (e) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- typings are not correct, it can be null in very rare cases | ||
if (!e.data || !isSetHeightMessage(e.data) || !window.parent) return; | ||
|
||
const data = e.data; | ||
|
||
ready(() => { | ||
window.parent.postMessage( | ||
{ | ||
type: 'setHeight', | ||
id: data.id, | ||
height: document.getElementsByTagName('html')[0].scrollHeight, | ||
}, | ||
'*', | ||
); | ||
}).catch((e) => { | ||
console.error('Error in setHeightMessage postMessage', e); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// This file will be loaded on settings pages, regardless of theme. | ||
|
||
import 'packs/public-path'; | ||
import Rails from '@rails/ujs'; | ||
|
||
Rails.delegate( | ||
document, | ||
'#edit_profile input[type=file]', | ||
'change', | ||
({ target }) => { | ||
if (!(target instanceof HTMLInputElement)) return; | ||
|
||
const avatar = document.querySelector<HTMLImageElement>( | ||
`img#${target.id}-preview`, | ||
); | ||
|
||
if (!avatar) return; | ||
|
||
let file: File | undefined; | ||
if (target.files) file = target.files[0]; | ||
|
||
const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc; | ||
|
||
if (url) avatar.src = url; | ||
}, | ||
); | ||
|
||
Rails.delegate(document, '.input-copy input', 'click', ({ target }) => { | ||
if (!(target instanceof HTMLInputElement)) return; | ||
|
||
target.focus(); | ||
target.select(); | ||
target.setSelectionRange(0, target.value.length); | ||
}); | ||
|
||
Rails.delegate(document, '.input-copy button', 'click', ({ target }) => { | ||
if (!(target instanceof HTMLButtonElement)) return; | ||
|
||
const input = target.parentNode?.querySelector<HTMLInputElement>( | ||
'.input-copy__wrapper input', | ||
); | ||
|
||
if (!input) return; | ||
|
||
const oldReadOnly = input.readOnly; | ||
|
||
input.readOnly = false; | ||
input.focus(); | ||
input.select(); | ||
input.setSelectionRange(0, input.value.length); | ||
|
||
try { | ||
if (document.execCommand('copy')) { | ||
input.blur(); | ||
|
||
const parent = target.parentElement; | ||
|
||
if (!parent) return; | ||
parent.classList.add('copied'); | ||
|
||
setTimeout(() => { | ||
parent.classList.remove('copied'); | ||
}, 700); | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
|
||
input.readOnly = oldReadOnly; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import classNames from 'classnames'; | ||
|
||
import DoneIcon from '@/material-icons/400-24px/done.svg?react'; | ||
|
||
import { Icon } from './icon'; | ||
|
||
interface Props { | ||
value: string; | ||
checked: boolean; | ||
name: string; | ||
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void; | ||
label: React.ReactNode; | ||
} | ||
|
||
export const CheckBox: React.FC<Props> = ({ | ||
name, | ||
value, | ||
checked, | ||
onChange, | ||
label, | ||
}) => { | ||
return ( | ||
<label className='check-box'> | ||
<input | ||
name={name} | ||
type='checkbox' | ||
value={value} | ||
checked={checked} | ||
onChange={onChange} | ||
/> | ||
|
||
<span className={classNames('check-box__input', { checked })}> | ||
{checked && <Icon id='check' icon={DoneIcon} />} | ||
</span> | ||
|
||
<span>{label}</span> | ||
</label> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.