mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-30 10:58:23 -05:00
Linkify studio descriptions
This commit is contained in:
parent
bc77b4b257
commit
536caf994a
2 changed files with 30 additions and 11 deletions
|
@ -12,6 +12,7 @@ import {
|
|||
} from '../../redux/studio-mutations';
|
||||
|
||||
import ValidationMessage from '../../components/forms/validation-message.jsx';
|
||||
import decorateText from '../../lib/decorate-text.jsx';
|
||||
|
||||
const errorToMessageId = error => {
|
||||
switch (error) {
|
||||
|
@ -32,18 +33,30 @@ const StudioDescription = ({
|
|||
});
|
||||
return (
|
||||
<div className="studio-info-section">
|
||||
<textarea
|
||||
rows="20"
|
||||
className={fieldClassName}
|
||||
disabled={isMutating || !canEditInfo || isFetching}
|
||||
defaultValue={description}
|
||||
onBlur={e => e.target.value !== description &&
|
||||
{ canEditInfo ? (
|
||||
<React.Fragment>
|
||||
<textarea
|
||||
rows="20"
|
||||
className={fieldClassName}
|
||||
disabled={isMutating || isFetching}
|
||||
defaultValue={description}
|
||||
onBlur={e => e.target.value !== description &&
|
||||
handleUpdate(e.target.value)}
|
||||
/>
|
||||
{descriptionError && <ValidationMessage
|
||||
mode="error"
|
||||
message={<FormattedMessage id={errorToMessageId(descriptionError)} />}
|
||||
/>}
|
||||
/>
|
||||
{descriptionError && <ValidationMessage
|
||||
mode="error"
|
||||
message={<FormattedMessage id={errorToMessageId(descriptionError)} />}
|
||||
/>}
|
||||
</React.Fragment>
|
||||
) : (
|
||||
<div className="studio-description studio-description-text">
|
||||
{decorateText(description, {
|
||||
usernames: true,
|
||||
hashtags: false,
|
||||
scratchLinks: true
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -79,6 +79,12 @@ $radius: 8px;
|
|||
.studio-description:disabled {
|
||||
background: $ui-blue-10percent;
|
||||
}
|
||||
.studio-description-text {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
height: 24rem;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.studio-follow-button {
|
||||
padding-top: 14px;
|
||||
|
|
Loading…
Reference in a new issue