js |
JavaScriptタグが付けられた新着投稿 - Qiita |
ActiveHashを用いたプルダウンメニューでの検索機能の備忘録 |
https://qiita.com/mrshouuge/items/24cd0b4484e97d619fe6
|
activehash |
2022-09-10 14:58:30 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
ActiveHashを用いたプルダウンメニューでの検索機能の備忘録 |
https://qiita.com/mrshouuge/items/24cd0b4484e97d619fe6
|
activehash |
2022-09-10 14:58:30 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【Ruby on Rails】愛犬管理アプリpart3 ~体調管理編~【初心者向け】 |
https://qiita.com/tak8_al/items/4f099c2597122bebb8df
|
rubyonrails |
2022-09-10 14:48:33 |
golang |
Goタグが付けられた新着投稿 - Qiita |
discordのwebhookを使用してgoから通知を送ってみた |
https://qiita.com/taiki-nd/items/ac9781e12ec7677d3ab7
|
参考文献 |
2022-09-10 14:23:37 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
ActiveHashを用いたプルダウンメニューでの検索機能の備忘録 |
https://qiita.com/mrshouuge/items/24cd0b4484e97d619fe6
|
activehash |
2022-09-10 14:58:30 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Ruby on Rails】愛犬管理アプリpart3 ~体調管理編~【初心者向け】 |
https://qiita.com/tak8_al/items/4f099c2597122bebb8df
|
rubyonrails |
2022-09-10 14:48:33 |
海外TECH |
DEV Community |
On-Call for QA Engineers |
https://dev.to/asaianudeep/on-call-for-qa-engineers-1c91
|
On Call for QA EngineersQA Engineers spend a considerable amount of time and effort in developing automation frameworks and even more on adding tests and maintaining them Given the flaky nature of these end to end automation tests most of the teams design some sort of alerting mechanism to get notified when there are test failures Communication platforms like slack or microsoft teams are becoming the new graveyard for these alerts as most engineers end up ignoring them over a period of time The primary reasons for ignoring these alerts areExcess AlertsLack of VisibilityPoor AccountabilityIn the following sections sample config files of Test Results Reporter cli tool are shared to follow the best practices while sending your test results to slack microsoft teams or any other communication platforms test results reporter reporter Publishes test results to Microsoft Teams Google Chat amp Slack Test Results ReporterPublish test results to Microsoft Teams Google Chat Slack and many more Targets Extensions Test Results Sample ReportsDocumentationNeed HelpWe use Github Discussions to receive feedback discuss ideas amp answer questions Head over to it and feel free to start a discussion We are always happy to help Support UsLike this project Star it on Github Your support means a lot to us Flask icons created by Freepik Flaticon View on GitHub Excess AlertsDuring the initial phases looking at these alerts in your slack channels or any other place is going to be fancy experience After some days we get used to ignoring them if there are more alerts than we can handle Due to this the real problems are lost in the noise One way to solve this is by sending the failure alerts to a different channel by keeping your primary channel clean and out of noise Primary Channel Failure Channel Config name slack inputs url lt primary channel webhook url gt publish test summary slim name slack condition fail inputs url lt failure channel webhook url gt publish failure details Lack of VisibilityTest Failure Analysis is where value is realised and quality is improved It is highly critical for the velocity of your releases Failures happen for a wide variety of reasons and keeping a track of these failure reasons is a tedious task ReportPortal is an AI powered test results portal It uses the collected history of executions and fail patterns to achieve hands free analysis of your latest results With auto analysing power it helps to distinguish between real failures and noise known failures or flaky tests It provides the following failure categoriesProduct Bug PB Automation Bug AB System Issue SI No Defect ND To Investigate TI Report Portal Analysis Config name report portal analysis inputs url lt report portal base url gt api key lt api key gt project lt project id gt launch id lt launch id gt Poor AccountabilityInvestigating and fixing the test failures is the most important part of maintaining automation test suites It makes the automation healthy and trustworthy One way we often see to infuse accountability is by asking the test owners who has written or adopted the tests to look at the failures In this approach the knowledge is restricted and creates a dependability on others Other way is to make the entire team responsible for all test failures It would be a disaster if the entire team tries investigate the same failure at the same time or no one takes a look at them assuming other are investigating It would be worth creating a roster for the person to look at the failures Auto tagging the person who is on call to investigate the test failures would definitely help in maintaining the automation suites healthy Mentions Config name mentions inputs schedule layers rotation every week users name Jon slack uid ULAKN name Anudeep slack uid ULAKM |
2022-09-10 05:28:43 |
海外TECH |
DEV Community |
🌈 Building an Animated and Accessible Command Menu in React |
https://dev.to/harshhhdev/building-an-animated-and-accessible-command-menu-in-react-5daj
|
Building an Animated and Accessible Command Menu in ReactHey everyone Over the past few months I ve been building my very own command menu component for React called kmenu In this post I want to go over how you can also create your OWN command menu I originally gave this talk at about building a command menu at React JAX and the recording should be up soon In the meanwhile you can follow this tutorial or the CodeSandbox Before we begin you can now check it out LIVE at over at kmenu hxrsh in and get started with the documentation over on the GitHub if you enjoy it don t forget to leave a star I m trying to reach stars soon BackgroundCommand menus have an interesting history and the idea stemmed from basically having a simple and easy way to navigate through an application The first example of this could be found in Sublime Text as they announced the beta of Sublime Text Pulled from their blog The Command Palette provides a quick way to access commands that don t warrant a key binding and would usually be hidden away in a menu For example turning Word Wrap on or off or changing the syntax highlighting mode of the current file It uses the same fuzzy matching as Goto Anything does meaning most commands are accessible with just a few key presses This worked like a power tool and led to more exploration and higher feature discoverability leading to it being adopted by code editors like Visual Studio Code It wasn t long until these command palettes made their way onto web applications Companies such as Vercel GitHub Sentry Linear Railway Raycast and MANY other web applications ended up adding a command menu to their websites as well Even desktop applications such as Discord Figma or Slack feature a command menu to help users navigate their complex interfaces with ease With that there are a few different approaches for adding a command menu to your website you can use an open source library like kmenu cmdk or kbar use a proprietary tool such as CommandBar or build your own This tutorial focuses on building your own implementation however you may not need to depending on whether or not you re satisfied with the other options available As said above in this post we ll be focusing on building our own command menu implementation Our menu will be accessible fully animated and you can customise it to your needs Getting StartedSince we ll be using Tailwind CSS I suggest you start by installing and configuring that Skip over this if your project already uses Tailwind Install Tailwind with peer dependenciesyarn add tailwindcss postcss autoprefixer D Generate the Tailwind and PostCSS configurationyarn tailwindcss init pNext open up your tailwind config js and add in your code directories under content This varies depending upon whether or not you re using something like Create React App or Next js This is also the time to import in any fonts For my project I m going to use Albert Sans the brand new font on Google Fonts As a side note I personally believe that Tailwind is an anti pattern but I ve only used it for the purposes of building this command menu quicker If your website doesn t already include Tailwind I heavily advocate that you use a regular CSS approach as opposed to this Make sure you also install Framer Motion a production ready motion library for React It ll help us in adding awesome motion animations to our command menu Adding CommandsFirst we ll create a commands tsx file at components Menu which will store all of our commands I m using react icons which essentially just bundles together all popular icon packs for easy use Anyways let s begin by creating a Command type before we create our array of objects import ReactElement from react export type Command icon ReactElement text string perform gt void It s super simple just an icon some text and a perform event which happens on click Next we ll create our command Create an array of objects of type Command and add in your commands import SiFramer SiTailwindcss SiApple SiVercel SiTwitter SiTesla SiArchlinux SiDeno SiFlutter SiGithub SiNike SiDiscord from react icons si export const commands Command icon lt SiFramer gt text Framer Motion perform gt window open blank icon lt SiTailwindcss gt text TailwindCSS perform gt window open blank icon lt SiApple gt text Apple perform gt window open blank icon lt SiArchlinux gt text Arch Linux perform gt window open blank icon lt SiVercel gt text Vercel perform gt window open blank icon lt SiTesla gt text Tesla perform gt window open blank icon lt SiDeno gt text Deno perform gt window open blank icon lt SiDiscord gt text Discord perform gt window open blank icon lt SiFlutter gt text Flutter perform gt window open blank icon lt SiGithub gt text GitHub perform gt window open blank icon lt SiNike gt text Nike perform gt window open blank icon lt SiTwitter gt text Twitter perform gt window open blank Building Our MenuNow that we finished adding commands let s get started building our menu Start by creating the skeleton which we ll gradually add features to const CommandMenu FC gt return lt motion div className flex items center justify center overflow hidden fixed w screen h screen select none bg eeee initial opacity animate opacity exit opacity gt lt motion div className w px will change auto relative bg white rounded lg shadow xl role dialog aria modal true gt lt div className flex items center h text xl pointer events none gt lt FiSearch className ml gt lt input placeholder Search for anything type text autoCapitalize false autoComplete false spellCheck false autoFocus className ml outline none w full pointer events none gt lt div gt lt motion ul className flex overflow y auto overflow x hidden flex col w full transition all will change auto max h px role listbox gt commands map command index gt our command component which we ll create later lt motion ul gt lt motion div gt lt motion div gt Creating The Command ComponentAwesome now that we have our skeleton let s create our command component This will be the thing that we map onto our command menu const Command FC lt command Command gt command gt return lt li gt lt a href className flex relative text lg items center h cursor pointer onClick command perform gt lt div className flex items center relative w full h full ml gt command icon lt p className max w w fit m overflow hidden text ellipsis text lg text black ml gt command text lt p gt lt div gt lt a gt lt div aria hidden true ref bottomRef gt lt li gt Awesome Now let s head back onto our main component make sure map the command component commands map command index gt lt Command key index command command gt Cool We should now see all of our commands on our screen They may not look very pretty but at least they work Implementing SearchSo as you may have seen this command menu has a search bar which you can use to search the commands For this we ll simply use two hook which contains an array of objects called results and another hook for the current query import type Command from commands tsx const query setQuery useState const results setResults useState lt Command null gt null Next we ll create a filter function to filter our commands based upon a string const filter query string Command gt commands filter command gt command text toLowerCase includes query toLowerCase Next we ll use a useEffect hook to update the results every time the user types something onto the search bar useEffect gt query setResults filter query setResults null query setQuery Awesome Now let s go inside our input component and make sure we update our setQuery hook on change lt input placeholder Search for anything type text autoCapitalize false autoComplete false spellCheck false autoFocus className ml outline none w full pointer events none onChange event gt setQuery event currentTarget value gt Next we need to make sure that we map our results instead of the original commands Head back into your map function and substitute commands for results results map command index gt lt Command key index command command gt Awesome Type something into your search bar it should work Handling Selection StatesOnto the next step handling which command is currently selected As you may have seen on the demo each command could be selected with the keyboard or if you hovered your mouse over it In kmenu I used a Reducer for this which is what I suggest you do if you re planning on expanding the features of this menu later on However for this we ll just use a simple useState hook const selected setSelected useState Firstly let s go inside our useEffect for updating our results and make sure we reset the state inside of there every time we search useEffect gt setSelected return query setResults filter query setResults null query setQuery Awesome Let s create a navigation function which we ll wrap around a useCallback which will contain logic for changing the selection with our keyboard This checks for things like whether or not we re at the start or end of our command menu and also works with using the tab keys const navigation useCallback event KeyboardEvent gt if results null const length results length if event key ArrowUp event key Tab amp amp event shiftKey event preventDefault setSelected gt selected selected else if event key ArrowDown event key Tab event preventDefault setSelected selected length length selected results selected Make sure you create a new useEffect hook for adding and removing event listeners useEffect gt window addEventListener keydown navigation return gt window removeEventListener keydown navigation navigation Cool Let s now go into our Command component and add in props to handle selection const Command FC lt command Command onMouseMove gt void selected boolean gt command onMouseMove selected gt and since we ve done that we need to change our map accordingly results map command index gt lt Command key index onMouseMove gt setSelected index selected selected index command command gt Next we ll create a perform function which would be inside a useCallback hook essentially checking whether or not the user has pressed the enter key and if the command is currently selected If it is then just run the perform function const perform useCallback event KeyboardEvent gt if event key Enter amp amp selected return command perform command selected useEffect gt window addEventListener keydown perform return gt window removeEventListener keydown perform Let s also make sure we select a command when we hover over it For this we ll pass in our onMouseMove prop onto our element lt a href className flex relative text lg items center h cursor pointer onMouseMove onMouseMove onClick command perform gt We should now be able to navigate through our command menu with our arrow keys and enter but we have no indication of which component we re currently on To do so let s add a bar which smoothly animates over onto our component when we select it selected amp amp lt motion div layoutId box className bg absolute w full h initial false aria hidden true transition type spring stiffness damping gt We re making some awesome progress and our command menu should now be navigable with our arrow keys or hovering over options Toggling The MenuLet s move onto another important toggling our command menu We ll also be using a hook for this const open setOpen useState false Awesome Let s create a function called toggle in which we handle the state of the bar for both computers and mobile phones const toggle event KeyboardEvent gt if event ctrlKey event metaKey amp amp event key k event preventDefault setOpen open gt open setQuery setResults null if event key Escape setOpen false setQuery setResults null const mobileToggle event TouchEvent gt if event touches length gt event preventDefault setOpen open gt open Here it checks if we ve pressed cmd k on our keyboard if we re on PC to toggle our menu If instead we ve pressed Escape it closes our menu For mobile phones it just checks if the user has double tapped on their screen to close the menu We will also work on toggling the menu if the user clicks outside later Anyways add more event listeners for these commands useEffect gt window addEventListener keydown toggle window addEventListener touchstart mobileToggle return gt window removeEventListener keydown toggle window removeEventListener touchstart mobileToggle Let s also go inside our navigation command and check if our bar is actually open so we don t disable tab functionality Just add a simple check at the top of the if statement and also add it to the dependency array const navigation useCallback event KeyboardEvent gt if results null amp amp open const length results length if event key ArrowUp event key Tab amp amp event shiftKey event preventDefault setSelected gt selected selected else if event key ArrowDown event key Tab event preventDefault setSelected selected length length selected results selected open After we ve done that we also need to make that our bar actually closes after we run a command For this we need to pass it in as a prop on the component const Command FC lt command Command onMouseMove gt void selected boolean setOpen Dispatch lt SetStateAction lt boolean gt gt gt command onMouseMove selected setOpen gt and after we ve done that let s just update our map function results map command index gt lt Command key index onMouseMove gt setSelected index selected selected index command command setOpen setOpen gt Now inside of our perform function just close the menu and add the hook to the dependency array const perform useCallback event KeyboardEvent gt if event key Enter amp amp selected setOpen false return command perform command selected setOpen Let s finish this off by actually creating a toggle state for the bar and toggling its appearance we ll be using AnimatePresence to animate components as they re removed from the React tree Let s move our entire component inside of this import AnimatePresence from framer motion return lt AnimatePresence gt open amp amp lt motion div className flex items center justify center overflow hidden fixed w screen h screen select none bg eeee initial opacity animate opacity exit opacity gt lt motion div className w px will change auto relative bg white rounded lg shadow xl role dialog aria modal true initial opacity y animate opacity y exit opacity y gt lt div className flex items center h text xl pointer events none gt lt FiSearch className ml gt lt input placeholder Search for anything type text autoCapitalize false autoComplete false spellCheck false autoFocus className ml outline none w full pointer events none onChange event gt setQuery event currentTarget value gt lt div gt lt motion ul className flex overflow y auto overflow x hidden flex col w full transition all will change auto max h px role listbox gt results map command index gt lt Command key index onMouseMove gt setSelected index selected selected index command command setOpen setOpen gt lt motion ul gt lt motion div gt lt motion div gt lt AnimatePresence gt Dynamically Setting Menu HeightIf you saw the bar at the beginning you have noticed that it expanded and shrunk based upon the amount of results To do this we can simply toggle the style prop of our listbox element containing our commands Since each command is px in height you can check this through inspect element we need to multiply our result length by and set our max height to a multiple of depending on how many components we want on there at max We also need to toggle overflow depending on this same parameter lt motion ul className flex overflow y auto overflow x hidden flex col w full transition all will change auto max h px role listbox style height results null results length overflowY results null amp amp results length gt scroll hidden gt Awesome Our menu should be resizing smoothly too as we have a transition property on there Scrolling Our MenuWe re almost done but we still have something crucial left scrolling our menu if we navigate it with our keyboard Thankfully we have an awesome Element scrollTo function for this purpose We ll also be using the Intersection Observer API to observe changes in the intersection of our listbox and command For this we ll begin by creating a custom React hook called useInView simply taking in a ref and telling us if it s visible within the parent import RefObject useEffect useState from react const useInView ref RefObject lt HTMLDivElement gt gt const intersecting setIntersecting useState false const observer new IntersectionObserver entry gt setIntersecting entry isIntersecting useEffect gt observer observe ref current return gt observer disconnect ref return intersecting export default useInViewGreat We now need two refs and two hooks to detect if it s in view at the top or the bottom and scrolling based upon that This might be a bit of a hacky duct tape solution but it works If you re unsatisfied with this approach it may be worth checking out the react intersection observer package const topRef useRef lt HTMLDivElement gt null const bottomRef useRef lt HTMLDivElement gt null const inViewTop useInView topRef const inViewBottom useInView bottomRef Let s create two divs and since they re non interactive we ll pass in aria hidden to hide it from the accessibility API const Command FC lt command Command onMouseMove gt void selected boolean setOpen Dispatch lt SetStateAction lt boolean gt gt gt command onMouseMove selected setOpen gt const topRef useRef lt HTMLDivElement gt null const bottomRef useRef lt HTMLDivElement gt null return lt li gt lt div aria hidden true ref topRef gt lt a href className flex relative text lg items center h cursor pointer onMouseMove onMouseMove onClick command perform gt selected amp amp lt motion div layoutId box className bg absolute w full h initial false aria hidden true transition type spring stiffness damping gt lt div className flex items center relative w full h full ml gt command icon lt p className max w w fit m overflow hidden text ellipsis text lg text black ml gt command text lt p gt lt div gt lt a gt lt div aria hidden true ref bottomRef gt lt li gt Great Now that we have that let s create a useEffect hook which takes care of scrolling our menu We ll just check if the component is selected and if it s viewable or not If it isn t then we ll just simply scroll to the element useEffect gt if selected amp amp inViewTop inViewBottom bottomRef current scrollIntoView behavior smooth block end inViewTop inViewBottom selected Awesome and that s all Our listbox should now be automatically scrollable if we navigate it with our arrow keys Final TouchesWe re almost done with our menu and the functionality is nearly complete Before we finish we have to check if the user has clicked outside our menu and close it accordingly For this we ll create a custom hook which takes in a ref and a handler We ll use event listeners for mobile and mouse to detect if the click or touch was inside our ref and close our menu accordingly import RefObject useEffect from react const useClickOutside ref RefObject lt HTMLDivElement gt handler gt void gt useEffect gt const listener event MouseEvent gt if ref current ref current contains event target as Node return handler const mobileListener event TouchEvent gt if ref current ref current contains event target as Node return handler document addEventListener mousedown listener document addEventListener touchstart mobileListener return gt document removeEventListener mousedown listener document removeEventListener mousedown listener handler ref export default useClickOutsideInside our main component let s just import it in and create a new ref for our menu import useClickOutside from hooks useClickOutside const menuRef useRef lt HTMLDivElement gt null useClickOutside menuRef gt setOpen false Additionally make sure to actually assign it to your dialog component lt motion div className w px will change auto relative bg white rounded lg shadow xl role dialog aria modal true initial opacity y animate opacity y exit opacity y ref menuRef gt Sheesh We just built our own command menu As a side note you can also change the placeholder colour inside our input to match your needs input placeholder apply text adbbd ConclusionAnyways with that we re finished If you have any errors setting up your command menu feel free to comment down below or check out the CodeSandbox for reference I m curious to see what you make with this command menu I think a good step forward to scaling this menu would be adding things like keywords categories or nested commands Feel free to share some cool things you ve made with this command menu Do remember to give kmenu a glance if you re interested in it it s packed with awesome features and functionality That s all for today until next time |
2022-09-10 05:11:52 |
海外TECH |
DEV Community |
i created oxideapi⚛api developing ecosystem in react js |
https://dev.to/sripadhs/i-created-oxideapiapi-developing-ecosystem-in-react-js-4d6f
|
i created oxideapiapi developing ecosystem in react jsHello my dearest developers today we are launching our own api developing ecosystem You can test apis in some seconds it is running as a web application It is very faster than other api testing tools like postman and all with your great support only we can update it make as a open source project Oxideapi Personal website |
2022-09-10 05:10:38 |
海外ニュース |
Japan Times latest articles |
Indo-Pacific nations agree to enter negotiations over U.S.-led economic framework |
https://www.japantimes.co.jp/news/2022/09/10/business/ipef-nations-negotiations/
|
Indo Pacific nations agree to enter negotiations over U S led economic frameworkIPEF members were able to share their understanding of the importance of supply chain resilience after disruptions caused by the pandemic and the invasion of |
2022-09-10 14:08:45 |
海外ニュース |
Japan Times latest articles |
Japan’s record percentage of working mothers masks low-paying jobs |
https://www.japantimes.co.jp/news/2022/09/10/business/japan-working-mothers-pay-gap/
|
masks |
2022-09-10 14:04:56 |
ニュース |
BBC News - Home |
National life after Queen's death: Will schools close? |
https://www.bbc.co.uk/news/uk-62844663?at_medium=RSS&at_campaign=KARANGA
|
holiday |
2022-09-10 05:49:14 |
ニュース |
BBC News - Home |
The Papers: King's 'pledge to the nation' and 'my darling mama' |
https://www.bbc.co.uk/news/blogs-the-papers-62856396?at_medium=RSS&at_campaign=KARANGA
|
death |
2022-09-10 05:16:42 |
ニュース |
BBC News - Home |
US Open: Carlos Alcaraz and Casper Ruud win to reach New York final |
https://www.bbc.co.uk/sport/tennis/62846443?at_medium=RSS&at_campaign=KARANGA
|
finals |
2022-09-10 05:40:22 |
北海道 |
北海道新聞 |
日本ハム近藤が通算千安打 |
https://www.hokkaido-np.co.jp/article/729151/
|
日本ハム |
2022-09-10 14:17:57 |
北海道 |
北海道新聞 |
美幌の婚姻届に「ポケモン」キャラ 提出第1号カップル誕生 |
https://www.hokkaido-np.co.jp/article/728785/
|
美幌 |
2022-09-10 14:20:18 |
北海道 |
北海道新聞 |
畑岡、首位と4打差の6位後退 米女子ゴルフ第2日 |
https://www.hokkaido-np.co.jp/article/729116/
|
女子ゴルフ |
2022-09-10 14:06:16 |
IT |
週刊アスキー |
ビッグウェーブさん、iPhone 14 Proのカメラ機能に大感激 |
https://weekly.ascii.jp/elem/000/004/105/4105078/
|
iphone |
2022-09-10 14:30:00 |
コメント
コメントを投稿