IT |
気になる、記になる… |
Apple、本日と明日の2日限定で「初売り」イベントを開催中 − 対象製品購入で最大24,000円分のApple Gift Cardを贈呈 |
https://taisy0.com/2022/01/02/150313.html
|
apple |
2022-01-01 15:00:44 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Linux Mintで画面の自動回転を行う。 |
https://qiita.com/gitHideaki/items/609aef11e68175d1a0cd
|
やってることは完全にLinuxのコマンドをPythonに叩かせているだけですえ笑シェルスクリプトでもいいんですがsubprocessPopenで叩いたコマンドの標準出力結果って変数に格納して継続監視できるのでmonitorsensorの傾き情報をログファイル等に用意すること無く傾きの検出することができるので必要なものはこのPythonスクリプト一つだけでOKと少しは作業の楽が出来るかなとちなみにモニターのleftupの状態が無いのは、YOGAの右側にいろいろ電源ボタンとかがあるので右側が下になると勝手に電源落としたりスリープになったりと誤作動をよく起こしたことがあり個人的な理由で抜きました。 |
2022-01-02 00:49:41 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
実行形式ファイルをPythonで作ってみた。 |
https://qiita.com/korehaRAYdayo/items/8f2900e04ee281e6cd7c
|
ちゃるずに課金しないで使い続けたいという熱い思い、、、分に回再起動するようにしたい、、、色々やってみた。 |
2022-01-02 00:49:21 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
気温予想AIを作ってみる |
https://qiita.com/TanakaSU/items/a382a2032c479f37ced2
|
相関係数を使えばどちらにすればいいかわかりそうですが、とりあえずどっちもやってみましょうRidgeRegression線形作成したAIモデルにスコアをつけるプログラム。 |
2022-01-02 00:48:46 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Pythonで始めるテストツール製作(2)オシロスコープの操作 |
https://qiita.com/pbjpkas/items/be69d2cb34eb7715170a
|
gtbIDNRIGOLTECHNOLOGIESDSZXXXXXXXXXXXXXXSP垂直軸スケールの取得と設定自動設定にてmVdivとなっています。 |
2022-01-02 00:40:43 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
テキストボックスの値をローカルストレージに保存したい |
https://teratail.com/questions/376291?rss=all
|
localstragesetitem |
2022-01-02 00:46:37 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
バックグラウンドイメージが反映されない |
https://teratail.com/questions/376290?rss=all
|
バックグラウンドイメージが反映されないscenenbspBuilderでバックグラウンドイメージを使っている時に、絶対パスだと上手くいきます。 |
2022-01-02 00:31:51 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
開発中のアプリをheroku上に反映する |
https://teratail.com/questions/376289?rss=all
|
開発中のアプリをheroku上に反映する前提・実現したいこと開発中のアプリをheroku上に反映したい発生している問題・エラーメッセージheroku上に反映する作業なのですが、反映途中で、ターミナル上にエラーが出ている。 |
2022-01-02 00:02:22 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Podmanをさわってみる |
https://qiita.com/khara_nasuo486/items/6ba4fe78c5b86e1d8a06
|
詳細は記事参照また、本筋と若干ずれますが、このDockerのコンテナランタイムには問題があり、Dockerの低レベルコンテナランタイムのrunCは、ホストのカーネル上で直接するアプリケーションを実行する仕組みのため、高速で動く代わりに、脆弱性があると危険という問題があります。 |
2022-01-02 00:56:46 |
海外TECH |
MakeUseOf |
Instagram's Plans and Priorities for 2022, According to Adam Mosseri |
https://www.makeuseof.com/instagram-plans-for-2022/
|
changes |
2022-01-01 15:01:57 |
海外TECH |
DEV Community |
Semantic HTML in React with zero new ideas |
https://dev.to/merri/semantic-html-in-react-with-zero-new-ideas-2gh9
|
Semantic HTML in React with zero new ideasHello New Year And welcome to yet another edition of my articles that have had zero planning and are simply written in one go Enjoy the effort since long term planning and me don t often go hand in hand I m about to take on a couple of known ideas and patterns and try to accomplish something that is seemingly unique Or at least it is just something that I have not encountered as is on the web What is wrong with how we do ReactOver the years working with React I ve grown frustrated on one particular thing the written JSX code rarely expresses the actual underlying HTML semantics What do I mean by this Let s have a look at a typical Styled Components solution SomeComponent style tsxexport const StyledList styled dl export const StyledListItem styled div export const StyledListTitle styled dt export const StyledListContent styled dd SomeComponent tsxfunction SomeComponent return lt StyledList gt lt StyledListItem gt lt StyledListTitle gt Title lt StyledListTitle gt lt StyledListContent gt Content lt StyledListContent gt lt StyledListItem gt lt StyledList gt Hey it is perfect DL semantics However when examining SomeComponent itself you see no trace of lt dl gt and the bunch Sure you can hover over the components and get type description which exposes that hey it is a styled dl element Or if you build a component library you can add documentation to a Storybook that tells how to use the components But this doesn t answer the core issue Young guys who have entered the industry in the past five or so years have a very hard time seeing the semantics How do you learn a thing that you never see in the code It is not really visible in the front of their eyes unless somebody is doing the shoveling actively With HTML this wouldn t be an issue But JSX is full of components that have nothing to do with HTML We need to get that actual HTML back to the game How do we do that Polymorfism vs CompositionI m not an expert with these terms and I m not going to do the research on what the actual meaning of these two are With code I admit I often care more about the solution than what people call it Anyway Styled Components describes their as property as a polymorphic feature It allows you to tell which component does the rendering Basically it is just this function Polymorphic as Component div props return lt Component props gt render as div lt Polymorphic gt Hello lt Polymorphic gt render as button lt Polymorphic as button gt Hello lt Polymorphic gt render as some framework Link component lt Polymorphic as Link gt Hello lt Polymorphic gt The biggest issue here is that the supported properties should depend on the passed component TypeScript does not support this This means that if you make a component that supposedly just provides styles and some usability or ay features on top whatever is given in well it adds a ton of complexity You are forced to limit the list of supported things making the feature less useful Most likely you only have styles and leave any other logic to some other layer and make a multitude of components to deal with the issues you have So you end up with things like lt Button gt lt LinkButton gt lt TextLink gt lt TextLinkButton gt and whatever else Although the issue in this particular example is that designers love to make visual links that have to act like buttons and visual buttons that have to act like links But that is a completely another issue and has more to do with process So what composition solutions can provide us lt FormControl element lt fieldset gt gt lt FormTitle element lt legend gt gt lt FormControl gt The major gripe with this solution is that we are rendering double first the element passed to element prop and then the same thing again with the composing component But then there is a reason to this madness Consider what this means when we re using another component lt Button element lt Link to gt gt lt HomeIcon gt Home lt Button gt The biggest advantage here is that we don t need to support Link properties in the Button component That is a very troublesome case in many frameworks that we currently have Users of Next Gatsby or React Router are likely very familiar with the issue the need of making your own additional special component wrapping an already specialized component More code to support more code Generic abstractionThe minimal internal implementation for a Button component with the help of Styled Components would look like this here would be CSS actuallyconst StyledButton styled button interface ButtonProps element JSX Element export function Button element ButtonProps return lt StyledButton as element type element props gt We still make use of polymorfism in this case but we don t have the type issues of a pure Styled Component In this case we re really handling all the element props outside of our component entirely and we simply wrap a styled component to provide styles for the button In this way the component itself becomes very focused and can real with just what it needs to do such as handle the styling concerns and added functionality This means we can have just one single button component to handle all the button needs So you can now pass in a button a link or maybe even some hot garbage like a div and make it look like a button But there is more You can also fix the usability of any given component so you can apply ARIA attributes such as role button and make sure all the accessibility guidelines are met The only requirement for a given element is that it needs to support and pass through DOM attributes If it doesn t well then we are doing work that never becomes effective However our main goal here is to make HTML semantics visible so in that sense this is a non issue Completing the Button componentSo why not go all the way in Let s make a Button component that makes almost anything work and look like a button import styled from styled components CSS that assumes any element and making it look like a buttonconst StyledButton styled button interface ButtonProps children React ReactNode element JSX Element function Button children element ButtonProps const props element lt button gt support lt button gt and lt input type button reset submit gt or a custom button that uses type prop const isButton element type button buttonTypes has props type it is really a link if it has href or to prop that has some content const isLink props href null props to null const draggable false onDragStart onKeyDown tabIndex type props const nextProps React HTMLProps lt any gt React useMemo gt make lt button gt default to type button if isButton amp amp type null return type button if isButton amp amp isLink return default to not allowing dragging draggable draggable prevent dragging the element in Firefox match native lt button gt behavior onDragStart onDragStart event React DragEvent gt event preventDefault Enter and Space must cause a click onKeyDown event React KeyboardEvent lt any gt gt consumer side handler is more important than we are if onKeyDown onKeyDown event check that we are still allowed to do what we want to do if event isDefaultPrevented event target instanceof HTMLElement return if Enter includes event key event target click let a possible third party DOM listener know that somebody is already handling this event event preventDefault role button tabIndex tabIndex return null draggable isButton isLink onDragStart onKeyDown tabIndex type ref may exist here but is not signaled in types so hack it const ref element as unknown as ref any return lt StyledButton as element type ref ref props nextProps gt children props children lt StyledButton gt Sure we didn t go for everything that a button could do We ignored the styles and we ignored all possible modifiers Instead we just focused on the core of what expectation of a button has to be Keyboard accessible with focus indicatorAnnounced as a button but keep real links as links Fix default form submit behavior as lt button gt is type submit if you don t let it know what it is In my experience it is better to be explicit about type submit Explicitly disable default dragging behavior buttons are not dragged Links however can still be dragged And do all this while letting user of the component still add extra features as needed The Developer ExperienceSo what was our goal again Oh yes Make that semantic HTML goodness visible So what have we got now lt Button gt Button lt Button gt HTML lt button class type button gt Button lt button gt lt Button element lt button type submit gt gt Submit button lt Button gt HTML lt button class type submit gt Submit button lt button gt lt Button element lt a href gt gt Link lt Button gt HTML lt a class href gt Link lt a gt lt Button element lt a gt gt Anchor lt Button gt HTML lt a class draggable false role button tabindex gt Anchor lt a gt lt Button element lt div gt gt Div lt Button gt HTML lt div class draggable false role button tabindex gt Div lt a gt lt Button element lt Link to gt gt Link component lt Button gt HTML lt a class href gt Link component lt a gt Looks good to me Most of the time you can see what the semantic element is Also you get the separation of concerns with the props onClick is not a possibly mysterious click handler but you can be sure it is going to be a native click method And the door is open for providing onClick from the Button component that doesn t provide event but instead something else Now the hard part is actually making all the components that would make use of this kind of composition and separation of concerns This way might not work for every single possible case like with select dropdown it is likely better keep the special unicorn implementation separate from a solution that makes use of native select element and all the handy usability features you get for free with it Without Styled ComponentsYou can also achieve this without Styled Components by using React cloneElement return React cloneElement element nextProps children props children However you need to deal with the styling most likely className handling on your own A small advantage we have here is that if consumer wants to have a ref we don t need to implement React forwardRef wrapper to our component We also don t need to hack with the ref variable like in the Styled Components implementation because element is passed to cloneElement and does know about it So that is one hackier side of code less in the implementation Closing wordsAs far as buttons go there are still a lot of little things on the CSS side that I think every button component should do However that is getting out of the topic and I guess this is becoming verbose enough as it is I hope you find this valuable I ve never liked living with Styled Components and preferring being a web browser side of guy not really with TypeScript either so I ve been looking into ways to make my life more tolerable Now that I am responsible for a company s component library I have finally the time to spend into thinking about the issues I feel rather good about where I ve now arrived I ve found something that lets me keep code minimal and as boilerplate free as possible while providing less components that give more However I m yet to implement the changes so for now we still live with some extra components that only exist to patch type issues |
2022-01-01 15:08:25 |
Apple |
AppleInsider - Frontpage News |
Best Deals January 1: $50 off Apple Watch Series 7, $73 Logitech MX Master 3, more! |
https://appleinsider.com/articles/22/01/01/best-deals-january-1-50-off-apple-watch-series-7-73-logitech-mx-master-3-more?utm_medium=rss
|
Best Deals January off Apple Watch Series Logitech MX Master more Appearing alongside Apple Watch discounts the best deals for New Years Day include off Amazon Echo Buds and a soldering station for Best Deals for January To help you search through the continuing holiday deal and January sale chaos we ve curated some of the best deals we could find on Apple products tech accessories and other things for the AppleInsider audience Read more |
2022-01-01 15:19:06 |
海外TECH |
Engadget |
Microsoft's Xbox Elite Series 2 controller is $40 off right now |
https://www.engadget.com/xbox-elite-wireless-controller-series-2-deal-sale140-dollars-153043869.html?src=rss
|
Microsoft x s Xbox Elite Series controller is off right nowIf you re still in the mood for some post holiday gifts to self Microsoft has cut the price on its high end Xbox Elite Series controller to That s almost as low as the Black Friday price of in case you missed out on that sale in late November Normally the highly customizable Elite Series is positioned as an upgrade for avid gamers with a slew of premium features including a set of six adjustable tension thumbsticks four paddles two d pads shorter hair trigger locks rubberized wraparound grips a carrying case and up to three custom profiles ーa handy thing if your attention is typically divided between several titles nbsp As for battery life the controller is rated for hours of wireless play time and there s also a charging dock in the package in addition to the charging case In addition to wireless connectivity via Bluetooth there s also the option of plugging in a USB C cable Either way the controller is compatible not just with Xbox games but PC titles too If you ve been eyeing the Series it s worth noting we don t see it on sale that often In fact stock itself seems to be low right now ーas of this writing Amazon doesn t even have inventory of the Series so the fact that Microsoft has it at all let alone at a close to Black Friday price seems notable Buy Elite Series at Microsoft |
2022-01-01 15:30:43 |
ニュース |
BBC News - Home |
Covid: More restrictions a last resort, Sajid Javid says |
https://www.bbc.co.uk/news/uk-59844761?at_medium=RSS&at_campaign=KARANGA
|
health |
2022-01-01 15:42:51 |
ニュース |
BBC News - Home |
New Year's Day is warmest on record in the UK, Met Office says |
https://www.bbc.co.uk/news/uk-59847641?at_medium=RSS&at_campaign=KARANGA
|
london |
2022-01-01 15:36:07 |
ニュース |
BBC News - Home |
Late goal gives Man City win at Arsenal in incident-packed encounter |
https://www.bbc.co.uk/sport/football/59787808?at_medium=RSS&at_campaign=KARANGA
|
league |
2022-01-01 15:22:32 |
ビジネス |
不景気.com |
2021年の最多リストラは「ホンダ」で2000名超、100名超31社 - 不景気.com |
https://www.fukeiki.com/2022/01/2021-restructuring-list.html
|
人員削減 |
2022-01-01 15:07:00 |
北海道 |
北海道新聞 |
復帰のアーセナル冨安はフル出場 イングランド、マンCに逆転負け |
https://www.hokkaido-np.co.jp/article/629468/
|
逆転負け |
2022-01-02 00:01:00 |
北海道 |
北海道新聞 |
クロップ監督がコロナ感染か 南野拓実所属のリバプール |
https://www.hokkaido-np.co.jp/article/629467/
|
南野拓実 |
2022-01-02 00:01:00 |
コメント
コメントを投稿