Skip to content

Commit

Permalink
Add data- attributes to statuses for userstyle selectors (mastodon#117)
Browse files Browse the repository at this point in the history
* Add data- attributes to statuses for userstyle selectors

* use const and template string, replace reblog->boosted and favourite->favourited

* more template strings because sorin-sama said so
  • Loading branch information
MightyPork committed Aug 4, 2017
1 parent 8b58153 commit f34f33c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/javascript/glitch/components/status/index.js
Expand Up @@ -664,6 +664,25 @@ backgrounds for collapsed statuses are enabled.
) background = attachments.getIn([0, 'preview_url']);
}

/*
Here we prepare extra data-* attributes for CSS selectors.
Users can use those for theming, hiding avatars etc via UserStyle
*/

const selectorAttribs = {
'data-status-by': `@${status.getIn(['account', 'acct'])}`,
};

if (prepend && account) {
const notifKind = {
favourite: 'favourited',
reblog: 'boosted',
}[prepend];

selectorAttribs[`data-${notifKind}-by`] = `@${account.get('acct')}`;
}

/*
Expand Down Expand Up @@ -694,6 +713,7 @@ collapsed.
),
}}
ref={handleRef}
{...selectorAttribs}
>
{prepend && account ? (
<StatusPrepend
Expand Down

0 comments on commit f34f33c

Please sign in to comment.