-
Notifications
You must be signed in to change notification settings - Fork 4
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
Using the media object VS creating a custom component #39
Comments
I just asked this same question today haha. I am leaning towards rewriting the styles.
If you re-use media object, then all the above would apply. My example was:
vs
The negative is it creates more CSS. However in the same article he suggest that "gzip would negate any difference in filesize anyway" (as it's a zipping tool that finds re-useable code). So the last thing I'm left with is what's the purpose of the media object if we go down that path? The last article I read where Harry mentioned it was this: So is it to be purely used on laying out content that's not a component? For example, a Title with a button to the right.
But then should that be a component? ie: c-page-header-title The only object I still use is grid layouts, wrapper, bands as they "house" the components chunks without messing the markup. But then those too can be confusing sometimes. For example, lets say you have a grid layout object. Then have a component called "best sellers" which uses o-grid-layout and c-cards. I guess a distinction has to be made at that point between programmatic components and styled components as best sellers (ie for shoes) might just be programming logic without any style changes. Another point, I've been following lots of Material Design principles and I find the media object quite rigid. Theres lots of 16px here, 8px here, 24px here. This doesn't really work that well with media, so you're best to create component classes if the out of the box ones aren't right for you. On a side note, the splitting up of objects and components when they are to be used together like the button still doesn't feel exactly right. Thoughts? |
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>
And they look like this btw:
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!
The text was updated successfully, but these errors were encountered: