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

fix: styling of components #72

Merged
merged 1 commit into from
Apr 23, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,9 @@
line-height: 150%;
margin-bottom: 8px;
margin-top: 8px;
margin-left: 56px;
}

.discord-attachment-root {
display: grid;
grid-auto-flow: row;
grid-row-gap: 0.25rem;
text-indent: 0;
min-height: 0;
min-width: 0;
padding-top: 0.125rem;
padding-bottom: 0.125rem;
}

.discord-attachment-root > * {
justify-self: start;
-ms-flex-item-align: start;
align-self: start;
}

.discord-attachment-root .discord-image-wrapper {
.discord-attachment .discord-image-wrapper {
display: block;
position: relative;
-webkit-user-select: text;
Expand All @@ -35,12 +17,3 @@
overflow: hidden;
border-radius: 3px;
}

.discord-attachment .discord-image-wrapper img {
position: absolute;
text-indent: -9999px;
}

img[alt] {
text-indent: -9999px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ export class DiscordAttachment implements ComponentInterface {
public render() {
return (
<Host class="discord-attachment">
<div class="discord-attachment-root">
<div class="discord-image-wrapper" style={{ height: `${this.height}px`, width: `${this.width}px` }}>
<img alt={this.alt} src={this.url} height={this.height} width={this.width} />
</div>
<div class="discord-image-wrapper" style={{ height: `${this.height}px`, width: `${this.width}px` }}>
<img alt={this.alt} src={this.url} height={this.height} width={this.width} />
</div>
</Host>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

.discord-embed .discord-embed-field .discord-field-title {
color: #ffffff;
font-weight: 500;
font-weight: 700;
font-size: 0.875rem;
line-height: 1.125rem;
min-width: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
grid-row-gap: 0.25rem;
min-height: 0;
min-width: 0;
padding-bottom: 0.125rem;
padding-top: 0.125rem;
text-indent: 0;
}

Expand Down Expand Up @@ -76,6 +74,7 @@
-webkit-box-align: center;
align-items: center;
color: #fff;
font-size: 0.875rem;
display: flex;
font-weight: 500;
grid-column: 1 / 1;
Expand All @@ -89,6 +88,7 @@

.discord-embed .discord-embed-author a {
color: #fff;
font-weight: 700;
}

.discord-light-theme .discord-embed .discord-embed-author a {
Expand Down Expand Up @@ -145,7 +145,6 @@

.discord-embed .discord-embed-image {
border-radius: 4px;
margin-top: 16px;
max-width: 100%;
}

Expand Down Expand Up @@ -188,7 +187,7 @@
.discord-embed .discord-embed-footer {
-webkit-box-align: center;
align-items: center;
color: #72767d;
color: #fff;
display: flex;
font-size: 0.85em;
grid-column: 1/3;
Expand All @@ -205,7 +204,7 @@
}

.discord-embed .discord-embed-footer .discord-footer-separator {
color: #3b3c42;
color: #fff;
font-weight: 700;
margin: 0 4px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ export class DiscordEmbed implements ComponentInterface {
<slot></slot>
</div>
<slot name="fields"></slot>
<div class={clsx('discord-embed-media', { 'discord-embed-media-video': Boolean(this.video) })}>{this.renderMedia()}</div>
{this.image || this.video ? (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this execute as (this.image || this.video) ? (...) : null or as this.image || (this.video ? (...) : null)?

If ESLint doesn't complain, I think it might be worth to wrap the OR condition with parens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This executes as the former based on comparison operations.

Prettier does complain however, so I think we are on the safe side with this:
image

<div class={clsx('discord-embed-media', { 'discord-embed-media-video': Boolean(this.video) })}>
{this.renderMedia()}
</div>
) : null}

{this.thumbnail ? <img src={this.thumbnail} alt="" class="discord-embed-thumbnail" /> : ''}
{(footerSlot || this.timestamp) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
.discord-message.discord-highlight-mention {
background-color: rgba(250, 166, 26, 0.1);
border-radius: 0 3px 3px 0;
margin-left: -3px;
padding-left: 3px;
padding-right: 5px;
position: relative;
background-color: rgba(250, 166, 26, 0.05);
padding-left: 0.85em;
}

.discord-light-theme .discord-message.discord-highlight-mention {
Expand All @@ -39,7 +38,7 @@
position: relative;
display: block;
top: 0;
left: -0.25rem;
left: -0.75rem;
bottom: 0;
pointer-events: none;
width: 2px;
Expand Down
37 changes: 25 additions & 12 deletions packages/core/src/components/discord-message/discord-message.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
color: #dcddde;
display: flex;
font-size: 0.9em;
padding: 0px 0.5em;
padding: 0px 1em;

position: relative;
word-wrap: break-word;
Expand All @@ -13,10 +13,8 @@
-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
padding-right: 16px;
padding-right: 0;
min-height: 1.375rem;
padding-top: 0.125rem;
padding-bottom: 0.125rem;
padding-right: 48px !important;
margin-top: 1.0625rem;
}
Expand Down Expand Up @@ -46,10 +44,6 @@
border-color: #eceeef;
}

.discord-message:last-of-type {
border-bottom-width: 0;
}

.discord-message a {
color: #0096cf;
font-weight: normal;
Expand All @@ -70,7 +64,7 @@

.discord-message .discord-author-avatar {
margin-right: 16px;
margin-top: 1px;
margin-top: 5px;
min-width: 40px;
}

Expand Down Expand Up @@ -103,13 +97,24 @@
width: 100%;
line-height: 160%;
font-weight: normal;
padding: 0;
padding-top: 2px;
}

.discord-message .discord-message-body {
word-break: break-word;
position: relative;
}

.discord-message .discord-message-body pre {
border: 1px solid #202225;
border-radius: 4px;
}

.discord-message .discord-message-body code {
background: #2f3136;
white-space: break-spaces;
}

.discord-light-theme .discord-message .discord-message-timestamp,
.discord-compact-mode .discord-message:hover .discord-message-timestamp,
.discord-compact-mode.discord-light-theme .discord-message:hover .discord-message-timestamp {
Expand All @@ -121,8 +126,16 @@
}

.discord-compact-mode .discord-message {
padding-top: 0.5em;
padding-bottom: 0.5em;
margin-top: unset;
}

.discord-message:first-of-type {
margin-top: 0.5rem;
}

.discord-message:last-of-type {
margin-bottom: 0.5rem;
border-bottom-width: 0;
}

.discord-compact-mode .discord-author-avatar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ export class DiscordMessage implements ComponentInterface {
});

return (
<Host class={clsx('discord-message row', { 'discord-highlight-mention': highlightMention })}>
<Host class={clsx('discord-message', { 'discord-highlight-mention': highlightMention })}>
<div class="discord-author-avatar">
<img src={profile.avatar} alt={profile.author} />
</div>
<div class="col-xs-8 discord-message-content">
<div class="discord-message-content">
{!parent.compactMode && (
<Fragment>
<AuthorInfo
Expand Down Expand Up @@ -125,9 +125,8 @@ export class DiscordMessage implements ComponentInterface {
{this.edited ? <span class="discord-message-edited">(edited)</span> : ''}
</div>
<slot name="embeds"></slot>
<slot name="attachments"></slot>
</div>

<slot name="attachments"></slot>
</Host>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
display: block;
font-size: 16px;
font-family: 'Roboto', sans-serif;
padding: 2px 8px;
line-height: 170%;
border: 1px solid rgba(255, 255, 255, 0.05);
}
Expand All @@ -20,9 +19,3 @@
.discord-messages.discord-no-background {
background-color: unset;
}

.col-xs-offset-0_25 {
margin-left: 2.0833333325%;
}

@import './flexboxgrid.min.css';

This file was deleted.