-
Notifications
You must be signed in to change notification settings - Fork 20
TipBox.vue: Support different size icons #124
Conversation
Ready for Review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the .icon-wrapper
change appears to be necessary.
My thoughts on styling: MarkBind/markbind#386 (comment), MarkBind/markbind#386 (comment)
Suggested usage:
<box icon=":rocket:" add-class="icon-large">
DUMMY TEXT
</box>
.icon-large i {
font-size: 3em;
}
src/TipBox.vue
Outdated
flex-direction: column; | ||
justify-content: center; | ||
align-content: center; | ||
font-size: medium; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we only need display
and align-content
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it without the flex-direction: column
, and the justify-content: center
. Here's what it looks like for large paragraphs -
Here's what it looks like without justify-content: center
(but with flex-direction: column
). While it does work for long paragraphs, single-line content is not properly aligned -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That appears to be because <slot></slot>
is directly in contents
, together with heading
and dismiss-button
.
I don't think it is appropriate to always centre the children in contents
though, particularly the heading
. Did we try extra-large
(maybe extremely-large) with heading
and/or dismissable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply. I've been trying out different things to make this work. You're right, the heading
and dismiss-button
don't behave well when I center-align the contents. Center-aligning the contents is much harder than I thought it would be 😅
I've tried wrapping the <slot>
in a <div>
and <span>
, but that doesn't work well. The next thing I tried was moving the heading
and button
outside the 'content's div
and make it a 3 column container (one for the icon, one for text, one for heading and button). The problem here is that the heading
messes with the text column if it is too long.
So, the latest thing I'm working on is separating out the heading
into a div
that would be placed on top of the container, effectively making it a 2-rowed container. The 2nd row will be a 3 column container, with the 3rd column only for the dismiss-button
.
Are there any better ways to deal with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say not to vertically center-align the contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright 👍
As mentioned above, usage: <box type="warning" add-class="icon-large">
DUMMY TEXT
</box> Will open a PR in markbind to add the CSS icon-size classes to the assets. |
Oh? I thought it is going to be |
I thought @acjh wanted to normalize it to using |
By the site's own CSS file, I meant like https://github.com/nus-cs2103/website-base/blob/master/css/main.css.
The styles are arbitrary (2em, 3em, extra-large). If we do this, then authors may expect MarkBind to add more styles like medium-large (2.5em), extra-extra-large (5em) and text sizes next. There is little value that MarkBind can add, especially since these can be achieved with plain CSS quite easily. MarkBind should go for pleasant styling, maybe with alternative defaults if reasonable, but we should draw the line between supporting the ability to do something (add-class and the other changes in this PR) and adding arbitrary styles. |
I agree with drawing the line somewhere. I'm also mindful that our target authors are expected to be able to use basic html-like syntax only whereas css editing is moving to web developer territory. As an author, I myself sometimes ask you guys for css hacks when I can't get MarkBind to do what I want. It's not something we can expect our target users to do (at least not the authors of education materials; might be OK for those writing project documentation if the project itself is a web project). So, it's good if we can minimize the need for css editing. For example, the box icon size vary between different site generators (ours seem to be the smallest) but probably the 4 proposed variations can cover the full range. That way, our box can be configured to be close to most of the common box styles. If the author wants some odd-sized icon, only then they should have to resort to css editing. Do you think it is OK to provide some built-in styles, like how Bootstrap does (e.g.,
|
I think that is not where MarkBind should be heading. Some investigation shows that Font Awesome already does sizing:
How about: <!-- Raw -->
<box type="warning" icon=":fas-camera:" icon-size="2x">
DUMMY TEXT
</box>
<!-- Rendered -->
<div class="alert container alert-warning">
<div class="icon-wrapper fa-2x">
<span><i class="fas fa-camera"></i></span>
</div>
<div class="contents">
DUMMY TEXT
</div>
</div> Note that |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your changes. We can clean up a little.
src/TipBox.vue
Outdated
<div v-if="!isDefault && !iconSize" class="icon-wrapper"> | ||
<span v-html="iconType"></span> | ||
</div> | ||
<div v-if="!isDefault && iconSize" class="icon-wrapper" :class="`fa-${iconSize}`" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do as done with lightStyle
:
<div v-if="!isDefault" class="icon-wrapper" :class="[iconStyle]">
src/TipBox.vue
Outdated
@@ -1,6 +1,6 @@ | |||
<template> | |||
<div class="alert container" :class="[boxStyle, addClass, lightStyle]" :style="customStyle"> | |||
<div v-if="!isDefault" class="icon-wrapper"> | |||
<div v-if="!isDefault" class="icon-wrapper" :class="[`fa-${iconSize}`]" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this result in class="fa-null"
if iconSize
not specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/TipBox.vue
Outdated
@@ -1,6 +1,6 @@ | |||
<template> | |||
<div class="alert container" :class="[boxStyle, addClass, lightStyle]" :style="customStyle"> | |||
<div v-if="!isDefault" class="icon-wrapper"> | |||
<div v-if="!isDefault" class="icon-wrapper" :class="`${iconSize ? `fa-${iconSize}`: ''}`" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do as done with lightStyle
as suggested in #124 (comment):
<div v-if="!isDefault" class="icon-wrapper" :class="[iconStyle]">
src/TipBox.vue
Outdated
@@ -1,6 +1,6 @@ | |||
<template> | |||
<div class="alert container" :class="[boxStyle, addClass, lightStyle]" :style="customStyle"> | |||
<div v-if="!isDefault" class="icon-wrapper"> | |||
<div v-if="!isDefault" class="icon-wrapper" :class="[iconStyle]" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove stray whitespace:
<div v-if="!isDefault" class="icon-wrapper" :class="[iconStyle]" > | |
<div v-if="!isDefault" class="icon-wrapper" :class="[iconStyle]"> |
src/TipBox.vue
Outdated
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Misplaced closing brace.
- Missing default return value.
iconStyle() {
if (this.iconSize) {
return `fa-${this.iconSize}`;
+ }
+ return '';
}
}
}
- }
28cd48f
to
eb77dd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to update the docs in the MarkBind repo.
closes MarkBind #986 (specifications of sizes can also be found there).
This is an enhancement to box icons.
Usage:
(Possible) Expected output(s):
icon-size="2x", single-para
![Screenshot 2020-01-30 at 10 03 24 PM](https://user-images.githubusercontent.com/21968718/73456145-58b64e80-43ac-11ea-8acd-8a9e615934ae.png)
icon-size="2x"
, multi-paraicon-size="2x"
, multi-para, no heading, not dismissible