-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi Harry,
I've seen this done both ways, and I think it comes down to personal preference more than anything else.
What are your thoughts about - or what are the pros and cons for - creating a component that could technically be done by just using the media object with modifier classes.
So I've created an alert, or feedback, component for global status messages used to give feedback or convey information to the user. I have four types: message, warning, error, success. It's basically a bar with a colored background, an icon, and of course text. Hence, it could be done using the media object.
Currently I'm using an icon font and placing it as a pseudo element on the parent container. I've been considering using inline SVGs, which would be well suited to using the media object, making this issue a moot point. But that's another question I have, icon font vs inline SVG...
So, my thinking was that since this is for a specific use and we have four message types, it would be 'easier' to implement by having this component, using a modifier class for each message type. Of course, this is what you would also do if you used the media object. The differences being that I'm moving the icon from the markup to the CSS, but also reducing the amount of markup and class names. This may be opinionated, but since we have a UI design, I know that that message type uses that icon. So I don't feel that in this instance, putting the icon in the CSS is giving up the control of defining it in the markup.
Instead of having something like this using the media object:
<div class="o-media c-alert c-alert--error" role="status">
<div class="o-media__img"><i class="my-fonticons--error"></i> - OR - <svg .../></div>
<div class="o-media__body">You have no chance to survive make your time.</div>
</div>
The component markup looks like this:
<div class="c-alert c-alert--message" role="status">
<div class="c-alert__body">How are you gentlemen!!</div>
</div>
<div class="c-alert c-alert--error" role="status">
<div class="c-alert__body">You have no chance to survive make your time.</div>
</div>
Unless I'm missing something, I don't think there is anything wrong with making a component like this. I'd love to hear your thoughts about it. Thanks for your time and all your great work!
